Skip to content

Commit

Permalink
Merge pull request #23 from rsteube/hidden-commands-flags
Browse files Browse the repository at this point in the history
support hidden commands/flags
  • Loading branch information
rsteube committed Oct 25, 2022
2 parents d4a8583 + 3e915ff commit 01e722f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/carapace_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ fn command_for(cmd: &clap::Command) -> Command {
positionalany: positionalany_completion_for(cmd),
..Default::default()
},
commands: cmd.get_subcommands().map(command_for).collect(),
commands: cmd
.get_subcommands()
.filter(|c| !c.is_hide_set())
.map(command_for)
.collect(),
..Default::default()
}
}
Expand All @@ -83,6 +87,7 @@ fn flags_for(cmd: &clap::Command) -> Map<String, String> {
let mut options = cmd
.get_opts()
.filter(|o| !o.is_positional())
.filter(|o| !o.is_hide_set())
.map(|x| x.to_owned())
.chain(generator::utils::flags(cmd))
.collect::<Vec<Arg>>();
Expand Down Expand Up @@ -145,6 +150,7 @@ fn flag_completions_for(cmd: &clap::Command) -> Map<String, Vec<String>> {
let mut options = cmd
.get_opts()
.filter(|o| !o.is_positional())
.filter(|o| !o.is_hide_set())
.map(|x| x.to_owned())
.chain(generator::utils::flags(cmd))
.collect::<Vec<Arg>>();
Expand Down
5 changes: 0 additions & 5 deletions tests/snapshots/special_commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ commands:
- name: some_cmd
description: tests other things
flags:
--config?: the other case to test
-V, --version: Print version information
- name: some-cmd-with-hyphens
aliases:
- hyphen
description: ''
flags:
-V, --version: Print version information
- name: some-hidden-cmd
description: ''
flags:
-V, --version: Print version information

0 comments on commit 01e722f

Please sign in to comment.