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 <a.cavalcanti@sisa.samsung.com>
This commit is contained in:
Adenilson Cavalcanti 2013-11-18 12:52:03 -08:00
parent b2adac0cf3
commit adaa6435ed

View file

@ -41,12 +41,13 @@ pub struct Opts {
headless: bool, headless: bool,
} }
fn print_usage(opts: &[groups::OptGroup]) { fn print_usage(app: &str, opts: &[groups::OptGroup]) {
let message = format!("Usage: ./servo [ options ... ] [URL]\n\twhere options include"); let message = format!("Usage: {} [ options ... ] [URL]\n\twhere options include", app);
println(groups::usage(message, opts)); println(groups::usage(message, opts));
} }
pub fn from_cmdline_args(args: &[~str]) -> Opts { pub fn from_cmdline_args(args: &[~str]) -> Opts {
let app_name = args[0].to_str();
let args = args.tail(); let args = args.tail();
let opts = ~[ 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") { 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 // TODO: how to return a null struct and let the caller know that
// it should abort? // it should abort?
fail!("") fail!("")
}; };
let urls = if opt_match.free.is_empty() { 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") fail!(~"servo asks that you provide 1 or more URLs")
} else { } else {
opt_match.free.clone() opt_match.free.clone()