From adaa6435ed33a032de739543df761bc205bec80e Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Mon, 18 Nov 2013 12:52:03 -0800 Subject: [PATCH] Following suggestion in the merge request, reuse the parameter passed to the function that has the application name (so in future, if the browser no longer is named 'servo', the code will continue to work fine). Signed-off-by: Adenilson Cavalcanti --- src/components/gfx/opts.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/gfx/opts.rs b/src/components/gfx/opts.rs index 3b6cd3bc61a..8ed3e9aa50e 100644 --- a/src/components/gfx/opts.rs +++ b/src/components/gfx/opts.rs @@ -41,12 +41,13 @@ pub struct Opts { headless: bool, } -fn print_usage(opts: &[groups::OptGroup]) { - let message = format!("Usage: ./servo [ options ... ] [URL]\n\twhere options include"); +fn print_usage(app: &str, opts: &[groups::OptGroup]) { + let message = format!("Usage: {} [ options ... ] [URL]\n\twhere options include", app); println(groups::usage(message, opts)); } pub fn from_cmdline_args(args: &[~str]) -> Opts { + let app_name = args[0].to_str(); let args = args.tail(); let opts = ~[ @@ -67,14 +68,14 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts { }; if opt_match.opt_present("h") || opt_match.opt_present("help") { - print_usage(opts); + print_usage(app_name, opts); // TODO: how to return a null struct and let the caller know that // it should abort? fail!("") }; let urls = if opt_match.free.is_empty() { - print_usage(opts); + print_usage(app_name, opts); fail!(~"servo asks that you provide 1 or more URLs") } else { opt_match.free.clone()