| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Simple command line interface to launching browsers. | 6 * Simple command line interface to launching browsers. |
| 7 * Uses the browser_controller framework. | 7 * Uses the browser_controller framework. |
| 8 * The usage is: | 8 * The usage is: |
| 9 * DARTBIN launch_browser.dart BROWSER_NAME URL | 9 * DARTBIN launch_browser.dart BROWSER_NAME URL |
| 10 * DARTBIN should be the checked in stable binary. | 10 * DARTBIN should be the checked in stable binary. |
| 11 */ | 11 */ |
| 12 | 12 |
| 13 import "dart:io"; | 13 import "dart:io"; |
| 14 import "browser_controller.dart"; | 14 import "browser_controller.dart"; |
| 15 import "utils.dart"; |
| 15 | 16 |
| 16 void printHelp() { | 17 void printHelp() { |
| 17 print("Usage pattern:"); | 18 print("Usage pattern:"); |
| 18 print("launch_browser.dart browser url"); | 19 print("launch_browser.dart browser url"); |
| 19 print("Supported browsers: ${Browser.SUPPORTED_BROWSERS}"); | 20 print("Supported browsers: ${Browser.SUPPORTED_BROWSERS}"); |
| 20 } | 21 } |
| 21 | 22 |
| 22 void main() { | 23 void main() { |
| 23 var args = new Options().arguments; | 24 var args = new Options().arguments; |
| 24 if (args.length != 2) { | 25 if (args.length != 2) { |
| 25 print("Wrong number of arguments, please pass in exactly two arguments"); | 26 print("Wrong number of arguments, please pass in exactly two arguments"); |
| 26 printHelp(); | 27 printHelp(); |
| 27 return; | 28 return; |
| 28 } | 29 } |
| 29 var name = args[0]; | 30 var name = args[0]; |
| 30 | 31 |
| 31 if (!Browser.supportedBrowser(name)) { | 32 if (!Browser.supportedBrowser(name)) { |
| 32 print("Specified browser not supported"); | 33 print("Specified browser not supported"); |
| 33 printHelp(); | 34 printHelp(); |
| 34 return; | 35 return; |
| 35 } | 36 } |
| 36 | 37 |
| 37 var executable = Locations.getBrowserExecutable(name, {}); | 38 var executable = Locations.getBrowserLocation(name, {}); |
| 38 var browser = new Browser.byName(name, executable); | 39 var browser = new Browser.byName(name, executable); |
| 39 browser.start(args[1]); | 40 browser.start(args[1]); |
| 40 } | 41 } |
| OLD | NEW |