diff options
author | Andrew Gallant <jamslam@gmail.com> | 2014-12-02 21:48:18 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2014-12-02 21:48:18 -0500 |
commit | 845bff49f6b280f23874ea695eb3f187321c301b (patch) | |
tree | 4951c79aeda93bfac68ff41a00cdb406abcad480 /src/main.rs | |
parent | 6dd3b0844ed5640aa9e7eb124f5eb1bde1683ff6 (diff) |
Add support for `--list` flag.
This makes it work better with tab completion.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 28a241c..74a5fdc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,6 +61,7 @@ Usage: xsv [options] Options: + --list List all commands available. -h, --help Display this message --version Print version info and exit @@ -69,6 +70,7 @@ Commands:", command_list!()); #[deriving(Decodable)] struct Args { arg_command: Option<Command>, + flag_list: bool, } fn main() { @@ -77,6 +79,11 @@ fn main() { .version(Some(util::version())) .decode()) .unwrap_or_else(|e| e.exit()); + if args.flag_list { + let msg = concat!("Installed commands:", command_list!()); + io::stdout().write_str(msg).unwrap(); + return; + } match args.arg_command { None => { os::set_exit_status(0); |