Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * Simple command line interface to launcing browsers. | |
| 7 * Uses the browser_controller framework. | |
| 8 * The usage is: | |
| 9 * DARTBIN launch_browser.dart BROWSER_NAME URL | |
|
kustermann
2013/05/29 11:02:34
You could add a comment that DARTBIN should be the
ricow1
2013/05/29 11:46:31
Done.
| |
| 10 */ | |
| 11 | |
| 12 import "dart:io"; | |
| 13 import "browser_controller.dart"; | |
| 14 | |
| 15 const List<String> SUPPORTED_BROWSERS = | |
| 16 const ['safari', 'ff', 'chrome']; | |
|
kustermann
2013/05/29 11:02:34
Please add a TODO for me to make this work with an
ricow1
2013/05/29 11:46:31
Done.
| |
| 17 | |
| 18 bool supportedBrowser(String browser) { | |
| 19 return SUPPORTED_BROWSERS.contains(browser); | |
| 20 } | |
| 21 | |
| 22 void printHelp() { | |
| 23 print(""" | |
| 24 Usage pattern: | |
| 25 launch_browser browser url | |
| 26 Supported browsers: $SUPPORTED_BROWSERS | |
| 27 """); | |
|
kustermann
2013/05/29 11:02:34
If you use three strings, you can indent then corr
ricow1
2013/05/29 11:46:31
Done.
| |
| 28 } | |
| 29 | |
| 30 void main() { | |
| 31 var args = new Options().arguments; | |
| 32 if (args.length != 2) { | |
| 33 print("Wrong number of arguments, please pass in exactly two arguments"); | |
| 34 printHelp(); | |
| 35 return; | |
| 36 } | |
| 37 if (!supportedBrowser(args[0])) { | |
| 38 print("Specified browser not supported"); | |
| 39 printHelp(); | |
| 40 return; | |
| 41 } | |
| 42 var browser = new Browser.byName(args[0]); | |
| 43 browser.start(args[1]); | |
| 44 | |
| 45 } | |
| OLD | NEW |