diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2021-03-28 19:07:22 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-28 19:07:22 +0000 |
commit | dbb01e65af551342bce1d3f4664b2c37a46b3f08 (patch) | |
tree | f9ce11b4602c5c97fc6c8e9d940e321fa2fa90f9 /src/args.rs | |
parent | (cargo-release) start next development iteration 0.12.2-alpha.0 (diff) | |
parent | Generate completions with `miniserve --print-completions <shell>` (diff) | |
download | miniserve-dbb01e65af551342bce1d3f4664b2c37a46b3f08.tar.gz miniserve-dbb01e65af551342bce1d3f4664b2c37a46b3f08.zip |
Merge pull request #482 from rouge8/shell-completions
Generate completions with `miniserve --print-completions <shell>`
Diffstat (limited to 'src/args.rs')
-rw-r--r-- | src/args.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/args.rs b/src/args.rs index 909a88f..d6cfc69 100644 --- a/src/args.rs +++ b/src/args.rs @@ -21,7 +21,7 @@ const ROUTE_ALPHABET: [char; 16] = [ about, global_settings = &[structopt::clap::AppSettings::ColoredHelp], )] -struct CliArgs { +pub struct CliArgs { /// Be verbose, includes emitting access logs #[structopt(short = "v", long = "verbose")] verbose: bool, @@ -131,6 +131,10 @@ struct CliArgs { /// Hide version footer #[structopt(short = "F", long = "hide-version-footer")] hide_version_footer: bool, + + /// Generate completion file for a shell + #[structopt(long = "print-completions", value_name = "shell")] + pub print_completions: Option<structopt::clap::Shell>, } /// Checks wether an interface is valid, i.e. it can be parsed into an IP address @@ -205,9 +209,7 @@ pub fn parse_header(src: &str) -> Result<HeaderMap, httparse::Error> { } /// Parses the command line arguments -pub fn parse_args() -> crate::MiniserveConfig { - let args = CliArgs::from_args(); - +pub fn parse_args(args: CliArgs) -> crate::MiniserveConfig { let interfaces = if !args.interfaces.is_empty() { args.interfaces } else { |