Skip to content

Commit

Permalink
fix(clap): print usage if command is missing
Browse files Browse the repository at this point in the history
Also, fixed config-dir substitution in flag's help message
  • Loading branch information
Byron committed Apr 29, 2015
1 parent 5320a48 commit 63e23dd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/mako/cli/lib/argparse.mako
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Configuration:
CONFIG_DIR_FLAG,
"A directory into which we will store our persistent data. Defaults to "
"a user-writable directory that we will create during the first invocation."
"[default: ${CONFIG_DIR}]",
"[default: %s" % CONFIG_DIR,
'folder',
))
Expand Down
2 changes: 2 additions & 0 deletions src/mako/cli/lib/engine.mako
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ impl<'n, 'a> Engine<'n, 'a> {
% endfor # each method
_ => {
err.issues.push(CLIError::MissingMethodError("${mangle_subcommand(resource)}".to_string()));
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
}
}
},
% endfor # each resource
_ => {
err.issues.push(CLIError::MissingCommandError);
writeln!(io::stderr(), "{}\n", ${SOPT}.usage()).ok();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rust/cli/cmn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl fmt::Display for CLIError {
writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info)
},
CLIError::MissingCommandError => writeln!(f, "Please specify the main sub-command"),
CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the {} command", cmd),
CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the '{}' command", cmd),
}
}
}
Expand Down

0 comments on commit 63e23dd

Please sign in to comment.