diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-08-15 13:14:33 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-08-15 13:14:33 +0200 |
commit | 002ef2f32f18fdc5cffc3e5a876eb72c9d33492e (patch) | |
tree | 83c8696f9d7100a8a3d1a91cc79842cdfda7f648 /tool | |
parent | 181c1c012e5655ea0f72a19574370c4bcd3db70a (diff) |
tool: Rework command line interface handling.
- Having the cli parser defined in a separate file allows us to
generate shell completions from it. Up to now, this is only done
for sq. Generalize it a bit so that we can do it for sqv too.
Diffstat (limited to 'tool')
-rw-r--r-- | tool/build.rs | 8 | ||||
-rw-r--r-- | tool/src/sq.rs | 4 | ||||
-rw-r--r-- | tool/src/sq_cli.rs (renamed from tool/src/cli.rs) | 0 |
3 files changed, 7 insertions, 5 deletions
diff --git a/tool/build.rs b/tool/build.rs index 7517a2fb..62247aa7 100644 --- a/tool/build.rs +++ b/tool/build.rs @@ -3,15 +3,17 @@ extern crate clap; use std::env; use clap::Shell; -include!("src/cli.rs"); +mod sq_cli { + include!("src/sq_cli.rs"); +} fn main() { let outdir = match env::var_os("OUT_DIR") { None => return, Some(outdir) => outdir, }; - let mut app = build(); + let mut sq = sq_cli::build(); for shell in &[Shell::Bash, Shell::Fish] { - app.gen_completions("sq", *shell, &outdir); + sq.gen_completions("sq", *shell, &outdir); } } diff --git a/tool/src/sq.rs b/tool/src/sq.rs index 2d0b3411..43ffe726 100644 --- a/tool/src/sq.rs +++ b/tool/src/sq.rs @@ -26,7 +26,7 @@ use sequoia_core::{Context, NetworkPolicy}; use sequoia_net::KeyServer; use sequoia_store::{Store, LogIter}; -mod cli; +mod sq_cli; mod commands; fn open_or_stdin(f: Option<&str>) -> Result<Box<io::Read>, failure::Error> { @@ -46,7 +46,7 @@ fn create_or_stdout(f: Option<&str>) -> Result<Box<io::Write>, failure::Error> { } fn real_main() -> Result<(), failure::Error> { - let matches = cli::build().get_matches(); + let matches = sq_cli::build().get_matches(); let policy = match matches.value_of("policy") { None => NetworkPolicy::Encrypted, diff --git a/tool/src/cli.rs b/tool/src/sq_cli.rs index b9dd138e..b9dd138e 100644 --- a/tool/src/cli.rs +++ b/tool/src/sq_cli.rs |