bug 1526938: geckodriver: ensure --help is listed in help message; r=whimboo
authorAndreas Tolfsen <ato@sny.no>
Mon, 18 Feb 2019 12:48:53 +0000
changeset 520656 561a8cb2db9b422f4af806b1bb0c7c8448b4d298
parent 520655 b2768473a2805ecf5b58aa0c341d1085d65bad96
child 520657 a02142b7aefff4ff6a57c7f11618d98369b5f8eb
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1526938
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1526938: geckodriver: ensure --help is listed in help message; r=whimboo For completeness, this makes sure the --help flag is included in its own help message. Depends on D19432 Differential Revision: https://phabricator.services.mozilla.com/D19433
testing/geckodriver/src/main.rs
--- a/testing/geckodriver/src/main.rs
+++ b/testing/geckodriver/src/main.rs
@@ -113,16 +113,17 @@ macro_rules! usage {
     ($fmt:expr, $($arg:tt)+) => {
         return Err(FatalError::Usage(format!($fmt, $($arg)+)));
     };
 }
 
 type ProgramResult<T> = result::Result<T, FatalError>;
 
 enum Operation {
+    Help,
     Version,
     Server {
         log_level: Option<Level>,
         address: SocketAddr,
         settings: MarionetteSettings,
     }
 }
 
@@ -155,17 +156,19 @@ fn parse_args(app: &mut App) -> ProgramR
     let marionette_port = match matches.value_of("marionette_port") {
         Some(x) => match u16::from_str(x) {
             Ok(x) => Some(x),
             Err(_) => usage!("invalid Marionette port"),
         },
         None => None,
     };
 
-    let op = if matches.is_present("version") {
+    let op = if matches.is_present("help") {
+        Operation::Help
+    } else if matches.is_present("version") {
         Operation::Version
     } else {
         let settings = MarionetteSettings {
             host: marionette_host.to_string(),
             port: marionette_port,
             binary,
             connect_existing: matches.is_present("connect_existing"),
             jsdebugger: matches.is_present("jsdebugger"),
@@ -177,16 +180,17 @@ fn parse_args(app: &mut App) -> ProgramR
         }
     };
 
     Ok(op)
 }
 
 fn inner_main(app: &mut App) -> ProgramResult<()> {
     match parse_args(app)? {
+        Operation::Help => print_help(app),
         Operation::Version => print_version(),
 
         Operation::Server {
             log_level,
             address,
             settings,
         } => {
             if let Some(ref level) = log_level {
@@ -289,16 +293,22 @@ fn make_app<'a, 'b>() -> App<'a, 'b> {
             Arg::with_name("log_level")
                 .long("log")
                 .takes_value(true)
                 .value_name("LEVEL")
                 .possible_values(&["fatal", "error", "warn", "info", "config", "debug", "trace"])
                 .help("Set Gecko log level"),
         )
         .arg(
+            Arg::with_name("help")
+                .short("h")
+                .long("help")
+                .help("Prints this message"),
+        )
+        .arg(
             Arg::with_name("version")
                 .short("V")
                 .long("version")
                 .help("Prints version and copying information"),
         )
 }
 
 fn get_program_name() -> String {