Repository: clap-rs/clap Branch: master Commit: 70f3bb31874f Files: 597 Total size: 3.2 MB Directory structure: gitextract_6cj3b3in/ ├── .cargo/ │ └── config.toml ├── .clippy.toml ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.yml │ │ ├── config.yml │ │ └── feature_request.yml │ ├── PULL_REQUEST_TEMPLATE.md │ ├── renovate.json5 │ ├── settings.yml │ └── workflows/ │ ├── audit.yml │ ├── bench-baseline.yml │ ├── ci.yml │ ├── committed.yml │ ├── post-release.yml │ ├── pre-commit.yml │ ├── release-notes.py │ ├── rust-next.yml │ ├── spelling.yml │ └── template.yml ├── .gitignore ├── .pre-commit-config.yaml ├── CHANGELOG.md ├── CITATION.cff ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── Makefile ├── README.md ├── clap_bench/ │ ├── Cargo.toml │ ├── benches/ │ │ ├── complex.rs │ │ ├── empty.rs │ │ ├── ripgrep.rs │ │ ├── rustup.rs │ │ └── simple.rs │ └── src/ │ └── lib.rs ├── clap_builder/ │ ├── CONTRIBUTING.md │ ├── Cargo.toml │ ├── README.md │ └── src/ │ ├── builder/ │ │ ├── action.rs │ │ ├── app_settings.rs │ │ ├── arg.rs │ │ ├── arg_group.rs │ │ ├── arg_predicate.rs │ │ ├── arg_settings.rs │ │ ├── command.rs │ │ ├── debug_asserts.rs │ │ ├── ext.rs │ │ ├── mod.rs │ │ ├── os_str.rs │ │ ├── possible_value.rs │ │ ├── range.rs │ │ ├── resettable.rs │ │ ├── str.rs │ │ ├── styled_str.rs │ │ ├── styling.rs │ │ ├── tests.rs │ │ ├── value_hint.rs │ │ └── value_parser.rs │ ├── derive.rs │ ├── error/ │ │ ├── context.rs │ │ ├── format.rs │ │ ├── kind.rs │ │ └── mod.rs │ ├── lib.rs │ ├── macros.rs │ ├── mkeymap.rs │ ├── output/ │ │ ├── fmt.rs │ │ ├── help.rs │ │ ├── help_template.rs │ │ ├── mod.rs │ │ ├── textwrap/ │ │ │ ├── core.rs │ │ │ ├── mod.rs │ │ │ ├── word_separators.rs │ │ │ └── wrap_algorithms.rs │ │ └── usage.rs │ ├── parser/ │ │ ├── arg_matcher.rs │ │ ├── error.rs │ │ ├── features/ │ │ │ ├── mod.rs │ │ │ └── suggestions.rs │ │ ├── matches/ │ │ │ ├── arg_matches.rs │ │ │ ├── matched_arg.rs │ │ │ ├── mod.rs │ │ │ └── value_source.rs │ │ ├── mod.rs │ │ ├── parser.rs │ │ └── validator.rs │ └── util/ │ ├── any_value.rs │ ├── color.rs │ ├── escape.rs │ ├── flat_map.rs │ ├── flat_set.rs │ ├── graph.rs │ ├── id.rs │ ├── mod.rs │ └── str_to_bool.rs ├── clap_complete/ │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── Cargo.toml │ ├── README.md │ ├── examples/ │ │ ├── completion-derive.rs │ │ ├── completion.rs │ │ ├── dynamic.rs │ │ └── exhaustive.rs │ ├── src/ │ │ ├── aot/ │ │ │ ├── generator/ │ │ │ │ ├── mod.rs │ │ │ │ └── utils.rs │ │ │ ├── mod.rs │ │ │ └── shells/ │ │ │ ├── bash.rs │ │ │ ├── elvish.rs │ │ │ ├── fish.rs │ │ │ ├── mod.rs │ │ │ ├── powershell.rs │ │ │ ├── shell.rs │ │ │ └── zsh.rs │ │ ├── engine/ │ │ │ ├── candidate.rs │ │ │ ├── complete.rs │ │ │ ├── custom.rs │ │ │ └── mod.rs │ │ ├── env/ │ │ │ ├── mod.rs │ │ │ └── shells.rs │ │ ├── lib.rs │ │ └── macros.rs │ └── tests/ │ ├── examples.rs │ ├── snapshots/ │ │ ├── aliases.bash │ │ ├── aliases.elvish │ │ ├── aliases.fish │ │ ├── aliases.ps1 │ │ ├── aliases.zsh │ │ ├── basic.bash │ │ ├── basic.elvish │ │ ├── basic.fish │ │ ├── basic.ps1 │ │ ├── basic.zsh │ │ ├── custom_bin_name.bash │ │ ├── custom_bin_name.elvish │ │ ├── custom_bin_name.fish │ │ ├── custom_bin_name.ps1 │ │ ├── custom_bin_name.zsh │ │ ├── external_subcommands.bash │ │ ├── external_subcommands.elvish │ │ ├── external_subcommands.fish │ │ ├── external_subcommands.ps1 │ │ ├── external_subcommands.zsh │ │ ├── feature_sample.bash │ │ ├── feature_sample.elvish │ │ ├── feature_sample.fish │ │ ├── feature_sample.ps1 │ │ ├── feature_sample.zsh │ │ ├── home/ │ │ │ ├── .gitignore │ │ │ ├── dynamic-env/ │ │ │ │ └── exhaustive/ │ │ │ │ ├── bash/ │ │ │ │ │ └── .bashrc │ │ │ │ ├── elvish/ │ │ │ │ │ └── elvish/ │ │ │ │ │ └── rc.elv │ │ │ │ ├── fish/ │ │ │ │ │ └── fish/ │ │ │ │ │ ├── completions/ │ │ │ │ │ │ └── exhaustive.fish │ │ │ │ │ └── config.fish │ │ │ │ └── zsh/ │ │ │ │ ├── .zshenv │ │ │ │ └── zsh/ │ │ │ │ └── _exhaustive │ │ │ └── static/ │ │ │ └── exhaustive/ │ │ │ ├── bash/ │ │ │ │ ├── .bashrc │ │ │ │ └── .inputrc │ │ │ ├── elvish/ │ │ │ │ └── elvish/ │ │ │ │ └── rc.elv │ │ │ ├── fish/ │ │ │ │ └── fish/ │ │ │ │ ├── completions/ │ │ │ │ │ └── exhaustive.fish │ │ │ │ └── config.fish │ │ │ ├── powershell/ │ │ │ │ └── powershell/ │ │ │ │ └── Microsoft.PowerShell_profile.ps1 │ │ │ └── zsh/ │ │ │ ├── .zshenv │ │ │ └── zsh/ │ │ │ └── _exhaustive │ │ ├── multi_value_option.bash │ │ ├── multi_value_option.elvish │ │ ├── multi_value_option.fish │ │ ├── multi_value_option.ps1 │ │ ├── multi_value_option.zsh │ │ ├── optional_multi_value_option.bash │ │ ├── optional_multi_value_option.elvish │ │ ├── optional_multi_value_option.fish │ │ ├── optional_multi_value_option.ps1 │ │ ├── optional_multi_value_option.zsh │ │ ├── optional_value_option.bash │ │ ├── optional_value_option.elvish │ │ ├── optional_value_option.fish │ │ ├── optional_value_option.ps1 │ │ ├── optional_value_option.zsh │ │ ├── quoting.bash │ │ ├── quoting.elvish │ │ ├── quoting.fish │ │ ├── quoting.ps1 │ │ ├── quoting.zsh │ │ ├── register_dynamic.fish │ │ ├── register_minimal.bash │ │ ├── special_commands.bash │ │ ├── special_commands.elvish │ │ ├── special_commands.fish │ │ ├── special_commands.ps1 │ │ ├── special_commands.zsh │ │ ├── sub_subcommands.bash │ │ ├── sub_subcommands.elvish │ │ ├── sub_subcommands.fish │ │ ├── sub_subcommands.ps1 │ │ ├── sub_subcommands.zsh │ │ ├── subcommand_last.bash │ │ ├── subcommand_last.elvish │ │ ├── subcommand_last.fish │ │ ├── subcommand_last.ps1 │ │ ├── subcommand_last.zsh │ │ ├── two_multi_valued_arguments.bash │ │ ├── two_multi_valued_arguments.elvish │ │ ├── two_multi_valued_arguments.fish │ │ ├── two_multi_valued_arguments.ps1 │ │ ├── two_multi_valued_arguments.zsh │ │ ├── value_hint.bash │ │ ├── value_hint.elvish │ │ ├── value_hint.fish │ │ ├── value_hint.ps1 │ │ ├── value_hint.zsh │ │ ├── value_terminator.bash │ │ ├── value_terminator.elvish │ │ ├── value_terminator.fish │ │ ├── value_terminator.ps1 │ │ └── value_terminator.zsh │ └── testsuite/ │ ├── bash.rs │ ├── common.rs │ ├── elvish.rs │ ├── engine.rs │ ├── fish.rs │ ├── general.rs │ ├── main.rs │ ├── powershell.rs │ └── zsh.rs ├── clap_complete_nushell/ │ ├── CHANGELOG.md │ ├── Cargo.toml │ ├── README.md │ ├── examples/ │ │ ├── nushell_completion.rs │ │ ├── sub_subcommands.rs │ │ └── test.rs │ ├── src/ │ │ └── lib.rs │ └── tests/ │ ├── common.rs │ ├── completion.rs │ ├── nushell.rs │ └── snapshots/ │ ├── aliases.nu │ ├── basic.nu │ ├── feature_sample.nu │ ├── home/ │ │ └── static/ │ │ └── test/ │ │ └── nu/ │ │ └── .config/ │ │ └── nushell/ │ │ ├── completions/ │ │ │ └── test.nu │ │ └── config.nu │ ├── positional_index.nu │ ├── quoting.nu │ ├── special_commands.nu │ ├── sub_subcommands.nu │ └── value_hint.nu ├── clap_derive/ │ ├── CONTRIBUTING.md │ ├── Cargo.toml │ ├── README.md │ └── src/ │ ├── attr.rs │ ├── derives/ │ │ ├── args.rs │ │ ├── into_app.rs │ │ ├── mod.rs │ │ ├── parser.rs │ │ ├── subcommand.rs │ │ └── value_enum.rs │ ├── dummies.rs │ ├── item.rs │ ├── lib.rs │ ├── macros.rs │ └── utils/ │ ├── doc_comments.rs │ ├── error.rs │ ├── mod.rs │ ├── spanned.rs │ └── ty.rs ├── clap_lex/ │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── Cargo.toml │ ├── README.md │ ├── src/ │ │ ├── ext.rs │ │ └── lib.rs │ └── tests/ │ └── testsuite/ │ ├── lexer.rs │ ├── main.rs │ ├── parsed.rs │ └── shorts.rs ├── clap_mangen/ │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── Cargo.toml │ ├── README.md │ ├── examples/ │ │ └── man.rs │ ├── src/ │ │ ├── lib.rs │ │ └── render.rs │ └── tests/ │ ├── snapshots/ │ │ ├── aliases.bash.roff │ │ ├── basic.bash.roff │ │ ├── configured_display_order_args.roff │ │ ├── configured_subcmd_order.roff │ │ ├── default_subcmd_order.roff │ │ ├── feature_sample.bash.roff │ │ ├── help_headings.bash.roff │ │ ├── hidden_option.bash.roff │ │ ├── multiple_optional_values.bash.roff │ │ ├── optional_value.bash.roff │ │ ├── optional_with_required_equals_value.bash.roff │ │ ├── possible_values.bash.roff │ │ ├── quoting.bash.roff │ │ ├── special_commands.bash.roff │ │ ├── sub_subcommand_help.roff │ │ ├── sub_subcommands.bash.roff │ │ ├── value_env.bash.roff │ │ ├── value_hint.bash.roff │ │ ├── value_name_without_arg.bash.roff │ │ ├── value_with_required_equals.bash.roff │ │ └── variadic_values.bash.roff │ └── testsuite/ │ ├── common.rs │ ├── main.rs │ └── roff.rs ├── committed.toml ├── deny.toml ├── examples/ │ ├── README.md │ ├── cargo-example-derive.md │ ├── cargo-example-derive.rs │ ├── cargo-example.md │ ├── cargo-example.rs │ ├── demo.md │ ├── demo.rs │ ├── derive_ref/ │ │ ├── augment_args.rs │ │ ├── augment_subcommands.rs │ │ ├── flatten_hand_args.rs │ │ ├── hand_subcommand.rs │ │ └── interop_tests.md │ ├── escaped-positional-derive.md │ ├── escaped-positional-derive.rs │ ├── escaped-positional.md │ ├── escaped-positional.rs │ ├── find.md │ ├── find.rs │ ├── git-derive.md │ ├── git-derive.rs │ ├── git.md │ ├── git.rs │ ├── multicall-busybox.md │ ├── multicall-busybox.rs │ ├── multicall-hostname.md │ ├── multicall-hostname.rs │ ├── pacman.md │ ├── pacman.rs │ ├── repl-derive.rs │ ├── repl.rs │ ├── tutorial_builder/ │ │ ├── 01_quick.md │ │ ├── 01_quick.rs │ │ ├── 02_app_settings.md │ │ ├── 02_app_settings.rs │ │ ├── 02_apps.md │ │ ├── 02_apps.rs │ │ ├── 02_crate.md │ │ ├── 02_crate.rs │ │ ├── 03_01_flag_bool.md │ │ ├── 03_01_flag_bool.rs │ │ ├── 03_01_flag_count.md │ │ ├── 03_01_flag_count.rs │ │ ├── 03_02_option.md │ │ ├── 03_02_option.rs │ │ ├── 03_02_option_mult.md │ │ ├── 03_02_option_mult.rs │ │ ├── 03_03_positional.md │ │ ├── 03_03_positional.rs │ │ ├── 03_03_positional_mult.md │ │ ├── 03_03_positional_mult.rs │ │ ├── 03_04_subcommands.md │ │ ├── 03_04_subcommands.rs │ │ ├── 03_05_default_values.md │ │ ├── 03_05_default_values.rs │ │ ├── 03_06_required.md │ │ ├── 03_06_required.rs │ │ ├── 04_01_enum.md │ │ ├── 04_01_enum.rs │ │ ├── 04_01_possible.md │ │ ├── 04_01_possible.rs │ │ ├── 04_02_parse.md │ │ ├── 04_02_parse.rs │ │ ├── 04_02_validate.md │ │ ├── 04_02_validate.rs │ │ ├── 04_03_relations.md │ │ ├── 04_03_relations.rs │ │ ├── 04_04_custom.md │ │ ├── 04_04_custom.rs │ │ └── 05_01_assert.rs │ ├── tutorial_derive/ │ │ ├── 01_quick.md │ │ ├── 01_quick.rs │ │ ├── 02_app_settings.md │ │ ├── 02_app_settings.rs │ │ ├── 02_apps.md │ │ ├── 02_apps.rs │ │ ├── 02_crate.md │ │ ├── 02_crate.rs │ │ ├── 03_01_flag_bool.md │ │ ├── 03_01_flag_bool.rs │ │ ├── 03_01_flag_count.md │ │ ├── 03_01_flag_count.rs │ │ ├── 03_02_option.md │ │ ├── 03_02_option.rs │ │ ├── 03_02_option_mult.md │ │ ├── 03_02_option_mult.rs │ │ ├── 03_03_positional.md │ │ ├── 03_03_positional.rs │ │ ├── 03_03_positional_mult.md │ │ ├── 03_03_positional_mult.rs │ │ ├── 03_04_subcommands.md │ │ ├── 03_04_subcommands.rs │ │ ├── 03_04_subcommands_alt.rs │ │ ├── 03_05_default_values.md │ │ ├── 03_05_default_values.rs │ │ ├── 03_06_optional.md │ │ ├── 03_06_optional.rs │ │ ├── 04_01_enum.md │ │ ├── 04_01_enum.rs │ │ ├── 04_02_parse.md │ │ ├── 04_02_parse.rs │ │ ├── 04_02_validate.md │ │ ├── 04_02_validate.rs │ │ ├── 04_03_relations.md │ │ ├── 04_03_relations.rs │ │ ├── 04_04_custom.md │ │ ├── 04_04_custom.rs │ │ └── 05_01_assert.rs │ └── typed-derive/ │ ├── builtin.md │ ├── builtin.rs │ ├── custom.md │ ├── custom.rs │ ├── fn_parser.md │ ├── fn_parser.rs │ ├── foreign_crate.rs │ ├── implicit.md │ ├── implicit.rs │ └── main.rs ├── release.toml ├── src/ │ ├── _concepts.rs │ ├── _cookbook/ │ │ ├── cargo_example.rs │ │ ├── cargo_example_derive.rs │ │ ├── escaped_positional.rs │ │ ├── escaped_positional_derive.rs │ │ ├── find.rs │ │ ├── git.rs │ │ ├── git_derive.rs │ │ ├── mod.rs │ │ ├── multicall_busybox.rs │ │ ├── multicall_hostname.rs │ │ ├── pacman.rs │ │ ├── repl.rs │ │ ├── repl_derive.rs │ │ └── typed_derive.rs │ ├── _derive/ │ │ ├── _tutorial.rs │ │ └── mod.rs │ ├── _faq.rs │ ├── _features.rs │ ├── _tutorial.rs │ ├── bin/ │ │ └── stdio-fixture.rs │ └── lib.rs ├── tests/ │ ├── builder/ │ │ ├── action.rs │ │ ├── app_settings.rs │ │ ├── arg_aliases.rs │ │ ├── arg_aliases_short.rs │ │ ├── arg_matches.rs │ │ ├── borrowed.rs │ │ ├── cargo.rs │ │ ├── command.rs │ │ ├── conflicts.rs │ │ ├── default_missing_vals.rs │ │ ├── default_vals.rs │ │ ├── delimiters.rs │ │ ├── derive_order.rs │ │ ├── display_order.rs │ │ ├── double_require.rs │ │ ├── empty_values.rs │ │ ├── env.rs │ │ ├── error.rs │ │ ├── flag_subcommands.rs │ │ ├── flags.rs │ │ ├── global_args.rs │ │ ├── groups.rs │ │ ├── help.rs │ │ ├── help_env.rs │ │ ├── hidden_args.rs │ │ ├── ignore_errors.rs │ │ ├── indices.rs │ │ ├── macros.rs │ │ ├── main.rs │ │ ├── multiple_occurrences.rs │ │ ├── multiple_values.rs │ │ ├── occurrences.rs │ │ ├── opts.rs │ │ ├── positionals.rs │ │ ├── posix_compatible.rs │ │ ├── possible_values.rs │ │ ├── propagate_globals.rs │ │ ├── require.rs │ │ ├── subcommands.rs │ │ ├── template_help.rs │ │ ├── tests.rs │ │ ├── unicode.rs │ │ ├── unique_args.rs │ │ ├── utf16.rs │ │ ├── utf8.rs │ │ ├── utils.rs │ │ └── version.rs │ ├── derive/ │ │ ├── app_name.rs │ │ ├── arguments.rs │ │ ├── author_version_about.rs │ │ ├── basic.rs │ │ ├── boxed.rs │ │ ├── custom_string_parsers.rs │ │ ├── default_value.rs │ │ ├── deny_warnings.rs │ │ ├── doc_comments_help.rs │ │ ├── explicit_name_no_renaming.rs │ │ ├── flags.rs │ │ ├── flatten.rs │ │ ├── generic.rs │ │ ├── groups.rs │ │ ├── help.rs │ │ ├── issues.rs │ │ ├── macros.rs │ │ ├── main.rs │ │ ├── markdown.rs │ │ ├── naming.rs │ │ ├── nested_subcommands.rs │ │ ├── non_literal_attributes.rs │ │ ├── occurrences.rs │ │ ├── options.rs │ │ ├── privacy.rs │ │ ├── raw_bool_literal.rs │ │ ├── raw_idents.rs │ │ ├── rename_all_env.rs │ │ ├── skip.rs │ │ ├── subcommands.rs │ │ ├── type_alias_regressions.rs │ │ ├── utf8.rs │ │ ├── utils.rs │ │ └── value_enum.rs │ ├── derive_ui/ │ │ ├── bool_value_enum.rs │ │ ├── bool_value_enum.stderr │ │ ├── clap_empty_attr.rs │ │ ├── clap_empty_attr.stderr │ │ ├── default_value_t_invalid.rs │ │ ├── default_value_t_invalid.stderr │ │ ├── default_values_t_invalid.rs │ │ ├── default_values_t_invalid.stderr │ │ ├── enum_flatten.rs │ │ ├── enum_flatten.stderr │ │ ├── enum_variant_not_args.rs │ │ ├── enum_variant_not_args.stderr │ │ ├── external_subcommand_misuse.rs │ │ ├── external_subcommand_misuse.stderr │ │ ├── external_subcommand_wrong_type.rs │ │ ├── external_subcommand_wrong_type.stderr │ │ ├── flatten_and_methods.rs │ │ ├── flatten_and_methods.stderr │ │ ├── flatten_enum_in_struct.rs │ │ ├── flatten_enum_in_struct.stderr │ │ ├── flatten_struct_in_enum.rs │ │ ├── flatten_struct_in_enum.stderr │ │ ├── group_name_attribute.rs │ │ ├── group_name_attribute.stderr │ │ ├── multiple_external_subcommand.rs │ │ ├── multiple_external_subcommand.stderr │ │ ├── non_existent_attr.rs │ │ ├── non_existent_attr.stderr │ │ ├── rename_all_wrong_casing.rs │ │ ├── rename_all_wrong_casing.stderr │ │ ├── skip_flatten.rs │ │ ├── skip_flatten.stderr │ │ ├── skip_subcommand.rs │ │ ├── skip_subcommand.stderr │ │ ├── skip_with_other_options.rs │ │ ├── skip_with_other_options.stderr │ │ ├── skip_without_default.rs │ │ ├── skip_without_default.stderr │ │ ├── struct_subcommand.rs │ │ ├── struct_subcommand.stderr │ │ ├── subcommand_and_flatten.rs │ │ ├── subcommand_and_flatten.stderr │ │ ├── subcommand_and_methods.rs │ │ ├── subcommand_and_methods.stderr │ │ ├── subcommand_on_struct.rs │ │ ├── subcommand_on_struct.stderr │ │ ├── subcommand_opt_opt.rs │ │ ├── subcommand_opt_opt.stderr │ │ ├── subcommand_opt_vec.rs │ │ ├── subcommand_opt_vec.stderr │ │ ├── tuple_struct.rs │ │ ├── tuple_struct.stderr │ │ ├── value_enum_non_unit.rs │ │ ├── value_enum_non_unit.stderr │ │ ├── value_enum_on_struct.rs │ │ ├── value_enum_on_struct.stderr │ │ ├── value_parser_unsupported.rs │ │ └── value_parser_unsupported.stderr │ ├── derive_ui.rs │ ├── examples.rs │ ├── macros.rs │ ├── ui/ │ │ ├── V_flag_stdout.toml │ │ ├── arg_required_else_help_stderr.toml │ │ ├── error_stderr.toml │ │ ├── h_flag_stdout.toml │ │ ├── help_cmd_stdout.toml │ │ ├── help_flag_stdout.toml │ │ └── version_flag_stdout.toml │ └── ui.rs └── typos.toml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .cargo/config.toml ================================================ [resolver] incompatible-rust-versions = "fallback" ================================================ FILE: .clippy.toml ================================================ allow-print-in-tests = true allow-expect-in-tests = true allow-unwrap-in-tests = true allow-dbg-in-tests = true disallowed-methods = [ { path = "std::option::Option::map_or", reason = "prefer `map(..).unwrap_or(..)` for legibility" }, { path = "std::option::Option::map_or_else", reason = "prefer `map(..).unwrap_or_else(..)` for legibility" }, { path = "std::result::Result::map_or", reason = "prefer `map(..).unwrap_or(..)` for legibility" }, { path = "std::result::Result::map_or_else", reason = "prefer `map(..).unwrap_or_else(..)` for legibility" }, { path = "std::iter::Iterator::for_each", reason = "prefer `for` for side-effects" }, { path = "std::iter::Iterator::try_for_each", reason = "prefer `for` for side-effects" }, ] doc-valid-idents = ["PowerShell", ".."] ================================================ FILE: .github/FUNDING.yml ================================================ github: clap-rs open_collective: clap ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.yml ================================================ name: Bug report description: An issue with clap, clap_complete, clap_derive, or clap_mangen labels: ["C-bug", "S-triage"] body: - type: checkboxes attributes: label: Please complete the following tasks options: - label: I have searched the [discussions](https://github.com/clap-rs/clap/discussions) required: true - label: I have searched the [open](https://github.com/clap-rs/clap/issues) and [rejected](https://github.com/clap-rs/clap/issues?q=is%3Aissue+label%3AS-wont-fix+is%3Aclosed) issues required: true - type: input attributes: label: Rust Version description: Output of `rustc -V` validations: required: true - type: input attributes: label: Clap Version description: Can be found in Cargo.lock or Cargo.toml of your project (i.e. `grep -C1 clap Cargo.lock`). PLEASE DO NOT PUT "latest" HERE, use precise version. Put `master` (or other branch) if you're using the repo directly. validations: required: true - type: textarea attributes: label: Minimal reproducible code description: Please write a minimal complete program which has this bug. Do not point to an existing repository. value: | ```rust fn main() {} ``` validations: required: true - type: textarea attributes: label: Steps to reproduce the bug with the above code description: A command like `cargo run -- options...` or multiple commands. validations: required: true - type: textarea attributes: label: Actual Behaviour description: When I do like *this*, *that* is happening and I think it shouldn't. validations: required: true - type: textarea attributes: label: Expected Behaviour description: I think *this* should happen instead. validations: required: true - type: textarea attributes: label: Additional Context description: Add any other context about the problem here. - type: textarea attributes: label: Debug Output description: | Compile clap with `debug` feature: ```toml [dependencies] clap = { version = "*", features = ["debug"] } ``` ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ blank_issues_enabled: true contact_links: - name: Ask a question about: For support or brainstorming url: https://github.com/clap-rs/clap/discussions/new ================================================ FILE: .github/ISSUE_TEMPLATE/feature_request.yml ================================================ name: Feature request description: Suggest an idea for this project labels: ["C-enhancement", "S-triage"] body: - type: checkboxes attributes: label: Please complete the following tasks options: - label: I have searched the [discussions](https://github.com/clap-rs/clap/discussions) required: true - label: I have searched the [open](https://github.com/clap-rs/clap/issues) and [rejected](https://github.com/clap-rs/clap/issues?q=is%3Aissue+label%3AS-wont-fix+is%3Aclosed) issues required: true - type: input attributes: label: Clap Version description: Can be found in Cargo.lock or Cargo.toml of your project (i.e. `grep clap Cargo.lock`). PLEASE DO NOT PUT "latest" HERE, use precise version. Put `master` (or other branch) if you're using the repo directly. validations: required: true - type: textarea attributes: label: Describe your use case description: Describe the problem you're trying to solve. This is not mandatory and we *do* consider features without a specific use case, but real problems have priority. validations: required: true - type: textarea attributes: label: Describe the solution you'd like description: Please explain what the wanted solution should look like. You are **strongly encouraged** to attach a snippet of (pseudo)code. validations: required: true - type: textarea attributes: label: Alternatives, if applicable description: A clear and concise description of any alternative solutions or features you've managed to come up with. - type: textarea attributes: label: Additional Context description: Add any other context about the feature request here. ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ ================================================ FILE: .github/renovate.json5 ================================================ { schedule: [ 'before 5am on the first day of the month', ], semanticCommits: 'enabled', commitMessageLowerCase: 'never', configMigration: true, dependencyDashboard: true, "pre-commit": { enabled: true }, customManagers: [ { customType: 'regex', managerFilePatterns: [ '/^rust-toolchain\\.toml$/', '/Cargo.toml$/', '/clippy.toml$/', '/^Makefile$/', '/^tests/derive_ui.rs$/', '/\\.clippy.toml$/', '/^\\.github/workflows/ci.yml$/', '/^\\.github/workflows/rust-next.yml$/', ], matchStrings: [ 'STABLE.*?(?\\d+\\.\\d+(\\.\\d+)?)', '(?\\d+\\.\\d+(\\.\\d+)?).*?STABLE', ], depNameTemplate: 'STABLE', packageNameTemplate: 'rust-lang/rust', datasourceTemplate: 'github-releases', }, { customType: 'regex', managerFilePatterns: [ '/^\\.github/workflows/pre-commit.yml$/', ], matchStrings: [ 'prek-version.*?(?\\d+\\.\\d+(\\.\\d+)?)', ], depNameTemplate: 'prek', packageNameTemplate: 'j178/prek', datasourceTemplate: 'github-releases', }, ], packageRules: [ { commitMessageTopic: 'Rust Stable', matchManagers: [ 'custom.regex', ], matchDepNames: [ 'STABLE', ], extractVersion: '^(?\\d+\\.\\d+)', // Drop the patch version schedule: [ '* * * * *', ], automerge: true, }, { commitMessageTopic: 'Prek', matchManagers: [ 'custom.regex', ], matchDepNames: [ 'prek', ], extractVersion: '^(?\\d+\\.\\d+\\.\\d+)', schedule: [ '* * * * *', ], automerge: true, }, // Goals: // - Keep version reqs low, ignoring compatible normal/build dependencies // - Take advantage of latest dev-dependencies // - Rollup safe upgrades to reduce CI runner load // - Help keep number of versions down by always using latest breaking change // - Have lockfile and manifest in-sync { matchManagers: [ 'cargo', ], matchDepTypes: [ 'build-dependencies', 'dependencies', ], matchCurrentVersion: '>=0.1.0', matchUpdateTypes: [ 'patch', ], enabled: false, }, { matchManagers: [ 'cargo', ], matchDepTypes: [ 'build-dependencies', 'dependencies', ], matchCurrentVersion: '>=1.0.0', matchUpdateTypes: [ 'minor', 'patch', ], enabled: false, }, { matchManagers: [ 'cargo', ], matchDepTypes: [ 'dev-dependencies', ], matchCurrentVersion: '>=0.1.0', matchUpdateTypes: [ 'patch', ], automerge: true, groupName: 'compatible (dev)', }, { matchManagers: [ 'cargo', ], matchDepTypes: [ 'dev-dependencies', ], matchCurrentVersion: '>=1.0.0', matchUpdateTypes: [ 'minor', 'patch', ], automerge: true, groupName: 'compatible (dev)', }, ], } ================================================ FILE: .github/settings.yml ================================================ # These settings are synced to GitHub by https://probot.github.io/apps/settings/ repository: description: "A full featured, fast Command Line Argument Parser for Rust" homepage: "docs.rs/clap" topics: "rust cli command-line argparse clap" has_issues: true has_projects: false has_wiki: false has_downloads: true default_branch: master # Preference: people do clean commits allow_merge_commit: true # Backup in case we need to clean up commits allow_squash_merge: true # Not really needed allow_rebase_merge: false allow_auto_merge: true delete_branch_on_merge: true squash_merge_commit_title: "PR_TITLE" squash_merge_commit_message: "PR_BODY" merge_commit_message: "PR_BODY" #labels: # - name: "A-builder" # description: "Area: Builder API" # color: '#f7e101' # - name: "A-derive" # description: "Area: #[derive]` macro API" # color: '#f7e101' # - name: "A-docs" # description: "Area: documentation, including docs.rs, readme, examples, etc..." # color: '#f7e101' # - name: "A-completion" # description: "Area: completion generator" # color: '#f7e101' # - name: "A-help" # description: "Area: Help or usage messages" # color: '#f7e101' # - name: "A-meta" # description: "Area: administrative question or tracking issue" # color: '#f7e101' # - name: "A-parsing" # description: "Area: Parser's logic and needs it changed somehow." # color: '#f7e101' # - name: "A-validators" # description: "Area: ArgMatches validation logic # color: '#f7e101' # - name: "C-bug" # description: "Category: Things not working as expected" # color: '#f5f1fd' # - name: "C-enhancement" # description: "Category: Raise on the bar on expectations" # color: '#f5f1fd' # - name: "C-tracking-issue" # description: "Category: A tracking issue for an unstable feature" # color: '#f5f1fd' # - name: "C-dependencies" # description: "Category: Updating dependencies" # color: '#f5f1fd' # - name: "E-easy" # description: "Call for participation: Experience needed to fix: Easy / not much" # color: '#02E10C' # - name: "E-medium" # description: "Call for participation: Experience needed to fix: Medium / intermediate" # color: '#02E10C' # - name: "E-hard" # description: "Call for participation: Experience needed to fix: Hard / a lot" # color: '#02E10C' # - name: "E-help-wanted" # description: "Call for participation: Help is requested to fix this issue." # color: '#02E10C' # - name: "S-triage" # description: "Status: New; needs maintainer attention." # color: '#D3DDDD' # - name: "S-blocked" # description: "Status: Blocked on something else such as an RFC or other implementation work." # color: '#D3DDDD' # - name: "S-experimental" # description: "Status: Ongoing experiment that does not require reviewing and won't be merged in its current state." # color: '#D3DDDD' # - name: "S-waiting-on-design" # description: "Status: Waiting on user-facing design to be resolved before implementing" # color: '#D3DDDD' # - name: "S-waiting-on-decision" # description: "Status: Waiting on a go/no-go before implementing" # color: '#D3DDDD' # - name: "S-waiting-on-mentor" # description: "Status: Needs elaboration on the details before doing a 'Call for participation'" # color: '#D3DDDD' # - name: "S-waiting-on-author" # description: "Status: This is awaiting some action (such as code changes or more information) from the author." # color: '#D3DDDD' # - name: "M-breaking-change" # description: "Meta: Implementing or merging this will introduce a breaking change." # color: '#E10C02' # - name: "M-unreviewed" # description: "Meta: Request for post-merge review." # color: '#E10C02' # This serves more as documentation. # Branch protection API was replaced by rulesets but settings isn't updated. # See https://github.com/repository-settings/app/issues/825 # # branches: # - name: master # protection: # required_pull_request_reviews: null # required_conversation_resolution: true # required_status_checks: # # Required. Require branches to be up to date before merging. # strict: false # contexts: ["CI", "Spell Check with Typos"] # enforce_admins: false # restrictions: null ================================================ FILE: .github/workflows/audit.yml ================================================ name: Security audit permissions: contents: read on: pull_request: paths: - '**/Cargo.toml' - '**/Cargo.lock' push: branches: - master env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: security_audit: permissions: issues: write # to create issues (actions-rs/audit-check) checks: write # to create check (actions-rs/audit-check) runs-on: ubuntu-latest # Prevent sudden announcement of a new advisory from failing ci: continue-on-error: true steps: - name: Checkout repository uses: actions/checkout@v6 - uses: actions-rs/audit-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} cargo_deny: permissions: issues: write # to create issues (actions-rs/audit-check) checks: write # to create check (actions-rs/audit-check) runs-on: ubuntu-latest strategy: matrix: checks: - bans licenses sources steps: - uses: actions/checkout@v6 - uses: EmbarkStudios/cargo-deny-action@v2 with: command: check ${{ matrix.checks }} rust-version: stable ================================================ FILE: .github/workflows/bench-baseline.yml ================================================ name: Benchmark Baseline permissions: contents: read on: push: branches: master jobs: bench: name: Binary Size permissions: checks: write strategy: matrix: build: [linux] include: - build: linux os: ubuntu-latest runs-on: "${{ matrix.os }}" steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - uses: Swatinem/rust-cache@v2 - name: Install Bencher uses: bencherdev/bencher@main - name: Build run: "cargo build --package clap --example git-derive -F derive --release" env: CARGO_PROFILE_RELEASE_STRIP: true - name: Report run: | bencher run \ --project $(echo "${{ github.repository }}" | sed 's/\//-/g') \ --branch "${{ github.ref_name }}" \ --testbed "${{ matrix.os }}" \ --token '${{ secrets.BENCHER_API_TOKEN }}' \ --github-actions '${{ secrets.GITHUB_TOKEN }}' \ --adapter json \ --file-size target/release/examples/git-derive ================================================ FILE: .github/workflows/ci.yml ================================================ name: CI permissions: contents: read on: pull_request: push: branches: - "*master" env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: ci: permissions: contents: none name: CI needs: [test, shell-integration, shell-integration-nu, check, ui, minimal-versions, lockfile, docs, rustfmt, clippy, cffconvert] runs-on: ubuntu-latest if: "always()" steps: - name: Failed run: exit 1 if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')" test: name: Test strategy: matrix: build: [linux, windows, mac, minimal, default, next] include: - build: linux os: ubuntu-latest rust: "stable" features: "full" - build: windows os: windows-latest rust: "stable" features: "full" - build: mac os: macos-latest rust: "stable" features: "full" - build: minimal os: ubuntu-latest rust: "stable" features: "minimal" - build: default os: ubuntu-latest rust: "stable" features: "default" - build: next os: ubuntu-latest rust: "stable" features: "next" continue-on-error: ${{ matrix.rust != 'stable' }} runs-on: ${{ matrix.os }} env: # Reduce amount of data cached CARGO_PROFILE_DEV_DEBUG: line-tables-only steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@v2 - name: Build run: make build-${{matrix.features}} - name: Test run: make test-${{matrix.features}} - name: Test (benches) run: make test-${{matrix.features}} ARGS='--workspace --benches' - name: Test (ultra-minimal) if: matrix.build == 'minimal' run: make test-minimal ARGS='--manifest-path Cargo.toml' - name: Test dynamic completions run: cargo test -p clap_complete -F unstable-dynamic shell-integration: name: Shell Integration runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - uses: Swatinem/rust-cache@v2 - name: Install shells if: runner.os == 'Linux' run: sudo apt-get install -y elvish fish zsh - name: clap_complete run: cargo test -p clap_complete -F unstable-dynamic -F unstable-shell-tests shell-integration-nu: name: Nushell Integration runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - uses: Swatinem/rust-cache@v2 - name: clap_complete_nu run: cargo test -p clap_complete_nushell -F unstable-shell-tests check: name: Check runs-on: ubuntu-latest strategy: fail-fast: false matrix: build: [msrv, wasm, wasm-wasi, debug, release] include: - build: msrv rust: "1.85" # MSRV target: x86_64-unknown-linux-gnu features: full - build: wasm rust: stable target: wasm32-unknown-unknown features: wasm - build: wasm-wasi rust: stable target: wasm32-wasip2 features: wasm - build: debug rust: stable target: x86_64-unknown-linux-gnu features: debug - build: release rust: stable target: x86_64-unknown-linux-gnu features: release steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install rust uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust }} targets: ${{ matrix.target }} - uses: Swatinem/rust-cache@v2 - name: Check run: make check-${{ matrix.features }} env: TOOLCHAIN_TARGET: ${{ matrix.target }} ui: name: UI Tests runs-on: ubuntu-latest strategy: fail-fast: false matrix: features: [default, next] steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: "1.94" # STABLE - uses: Swatinem/rust-cache@v2 - name: UI Tests run: make test-ui-${{ matrix.features }} minimal-versions: name: Minimal versions strategy: matrix: os: ["ubuntu-latest"] runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install stable Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - name: Install nightly Rust uses: dtolnay/rust-toolchain@stable with: toolchain: nightly - name: Downgrade dependencies to minimal versions run: cargo +nightly generate-lockfile -Z minimal-versions - name: Compile with minimal versions run: cargo +stable check --workspace --all-features --locked --exclude clap_complete_nushell --exclude clap_bench lockfile: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - uses: Swatinem/rust-cache@v2 - name: "Is lockfile updated?" run: cargo update --workspace --locked docs: name: Docs runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: "1.94" # STABLE - uses: Swatinem/rust-cache@v2 - name: Check documentation env: RUSTDOCFLAGS: -D warnings run: make doc rustfmt: name: rustfmt runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: "1.94" # STABLE components: rustfmt - uses: Swatinem/rust-cache@v2 - name: Check formatting run: cargo fmt --check clippy: name: clippy runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: "1.94" # STABLE components: clippy - uses: Swatinem/rust-cache@v2 - name: Lint (ultra-minimal) run: make clippy-minimal ARGS='--manifest-path Cargo.toml' - name: Lint (minimal) run: make clippy-minimal - name: Lint (all) run: make clippy-full - name: Lint (release) run: make clippy-release cffconvert: name: cffconvert runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v6 with: persist-credentials: false - name: CFF validation uses: citation-file-format/cffconvert-github-action@2.0.0 with: args: --validate ================================================ FILE: .github/workflows/committed.yml ================================================ # Not run as part of pre-commit checks because they don't handle sending the correct commit # range to `committed` name: Lint Commits on: [pull_request] permissions: contents: read env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: committed: name: Lint Commits runs-on: ubuntu-latest steps: - name: Checkout Actions Repository uses: actions/checkout@v6 with: fetch-depth: 0 - name: Lint Commits uses: crate-ci/committed@master ================================================ FILE: .github/workflows/post-release.yml ================================================ name: post-release on: push: tags: - "v*" permissions: contents: read jobs: create-release: permissions: contents: write # for actions/create-release to create a release name: create-release runs-on: ubuntu-latest outputs: upload_url: ${{ steps.release.outputs.upload_url }} release_version: ${{ env.RELEASE_VERSION }} steps: - name: Get the release version from the tag shell: bash if: env.RELEASE_VERSION == '' run: | # See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027 echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV echo "version is: ${{ env.RELEASE_VERSION }}" - name: Checkout repository uses: actions/checkout@v6 with: fetch-depth: 1 - name: Generate Release Notes run: | ./.github/workflows/release-notes.py --tag ${{ env.RELEASE_VERSION }} --output notes-${{ env.RELEASE_VERSION }}.md cat notes-${{ env.RELEASE_VERSION }}.md - name: Create GitHub release id: release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ env.RELEASE_VERSION }} release_name: ${{ env.RELEASE_VERSION }} body_path: notes-${{ env.RELEASE_VERSION }}.md ================================================ FILE: .github/workflows/pre-commit.yml ================================================ name: pre-commit permissions: {} # none on: pull_request: push: branches: [master] env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: pre-commit: permissions: contents: read runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: j178/prek-action@v1 with: prek-version: '0.2.27' ================================================ FILE: .github/workflows/release-notes.py ================================================ #!/usr/bin/env python3 import argparse import re import pathlib import sys _STDIO = pathlib.Path("-") def main(): parser = argparse.ArgumentParser() parser.add_argument("-i", "--input", type=pathlib.Path, default="CHANGELOG.md") parser.add_argument("--tag", required=True) parser.add_argument("-o", "--output", type=pathlib.Path, required=True) args = parser.parse_args() if args.input == _STDIO: lines = sys.stdin.readlines() else: with args.input.open() as fh: lines = fh.readlines() version = args.tag.lstrip("v") note_lines = [] for line in lines: if line.startswith("## ") and version in line: note_lines.append(line) elif note_lines and line.startswith("## "): break elif note_lines: note_lines.append(line) notes = "".join(note_lines).strip() if args.output == _STDIO: print(notes) else: args.output.write_text(notes) if __name__ == "__main__": main() ================================================ FILE: .github/workflows/rust-next.yml ================================================ name: rust-next permissions: contents: read on: schedule: - cron: '3 3 3 * *' env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: test: name: Test strategy: matrix: build: [stable, linux, windows, mac, nightly, minimal, default, next] include: - build: stable os: ubuntu-latest rust: "stable" features: "full" - build: linux os: ubuntu-latest rust: "beta" features: "full" - build: windows os: windows-latest rust: "beta" features: "full" - build: mac os: macos-latest rust: "beta" features: "full" - build: nightly os: ubuntu-latest rust: "nightly" features: "full" - build: minimal os: ubuntu-latest rust: "stable" features: "minimal" - build: default os: ubuntu-latest rust: "stable" features: "default" - build: next os: ubuntu-latest rust: "stable" features: "next" continue-on-error: ${{ matrix.rust != 'stable' }} runs-on: ${{ matrix.os }} env: # Reduce amount of data cached CARGO_PROFILE_DEV_DEBUG: line-tables-only steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@v2 - name: Install shells if: runner.os == 'Linux' run: sudo apt-get install -y elvish fish zsh - name: Build run: make build-${{matrix.features}} - name: Test run: make test-${{matrix.features}} - name: Test (benches) run: make test-${{matrix.features}} ARGS='--workspace --benches' - name: Test (ultra-minimal) if: matrix.build == 'minimal' run: make test-minimal ARGS='--manifest-path Cargo.toml' - name: Test dynamic completions run: cargo test -p clap_complete -F unstable-dynamic latest: name: "Check latest dependencies" strategy: matrix: build: [stable] include: - build: stable os: ubuntu-latest rust: "stable" features: "full" runs-on: ${{ matrix.os }} env: CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: allow steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - uses: Swatinem/rust-cache@v2 - uses: taiki-e/install-action@cargo-hack - name: Install shells if: runner.os == 'Linux' run: sudo apt-get install -y elvish fish zsh - name: Update dependencies run: cargo update - name: Build run: make build-${{matrix.features}} - name: Test run: make test-${{matrix.features}} - name: Test (benches) run: make test-${{matrix.features}} ARGS='--workspace --benches' - name: Test (ultra-minimal) if: matrix.build == 'minimal' run: make test-minimal ARGS='--manifest-path Cargo.toml' - name: Test dynamic completions run: cargo test -p clap_complete -F unstable-dynamic ================================================ FILE: .github/workflows/spelling.yml ================================================ name: Spelling permissions: contents: read on: [pull_request] env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: spelling: name: Spell Check with Typos runs-on: ubuntu-latest steps: - name: Checkout Actions Repository uses: actions/checkout@v6 - name: Spell Check Repo uses: crate-ci/typos@master ================================================ FILE: .github/workflows/template.yml ================================================ name: Template Update permissions: contents: read on: schedule: - cron: '1 1 1 * *' workflow_dispatch: env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 TEMPLATE_URL: "https://github.com/epage/_rust.git" TEMPLATE_BRANCH: "main" concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: update: permissions: security-events: write # to create PR pull-requests: write contents: write # to push the branch runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v6 with: fetch-depth: 0 - name: Configure git run: | git config --global user.name '${{ github.actor }}' git config --global user.email '<>' - name: Fetch template run: "git remote add template ${{ env.TEMPLATE_URL }} && git fetch template ${{ env.TEMPLATE_BRANCH }}" - name: Merge template run: "git checkout -b template-update && git merge template/${{ env.TEMPLATE_BRANCH }} -m 'chore: Update from template'" - name: Clear any existing branch run: "git push origin --delete template-update" continue-on-error: true env: GH_TOKEN: ${{ github.token }} - name: Push branch run: "git push --set-upstream origin template-update" env: GH_TOKEN: ${{ github.token }} - name: Create PR run: "gh pr create --head template-update --title 'chore: Update from template' --body ''" env: GH_TOKEN: ${{ github.token }} - name: Merge PR run: "gh pr merge --auto --delete-branch" env: GH_TOKEN: ${{ github.token }} ================================================ FILE: .gitignore ================================================ target ================================================ FILE: .pre-commit-config.yaml ================================================ exclude: | (?x)^( tests/.*| CHANGELOG.md )$ default_install_hook_types: ["pre-commit", "commit-msg"] repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: - id: check-yaml - id: check-json - id: check-toml - id: check-merge-conflict - id: check-case-conflict - id: detect-private-key - repo: https://github.com/crate-ci/typos rev: v1.44.0 hooks: - id: typos - repo: https://github.com/crate-ci/committed rev: v1.1.11 hooks: - id: committed ================================================ FILE: CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/). ## 5.0.0 - TBD *available through `unstable-v5` feature flag* ### Breaking Changes - Made `ArgPredicate` `non_exhaustive` - *(help)* Change default `Command::term_width` to "source format" - *(help)* Change default `Command::max_term_width` to 100 - *(derive)* `Vec>` types are now assuming to capture occurrences - *(derive)* `ValueEnum` variants now use the full doc comment, not summary, for `PossibleValue::help` ### Features - *(derive)* Group values by their occurrence with `Vec>` ## [Unreleased] - ReleaseDate ## [4.6.0] - 2026-03-12 ### Compatibility - Update MSRV to 1.85 ## [4.5.61] - 2026-03-12 ### Internal - Update dependencies ## [4.5.60] - 2026-02-19 ### Fixes - *(help)* Quote empty default values, possible values ## [4.5.59] - 2026-02-16 ### Fixes - `Command::ignore_errors` no longer masks help/version on subcommands ## [4.5.58] - 2026-02-11 ## [4.5.57] - 2026-02-03 ### Fixes - Regression from 4.5.55 where having an argument with `.value_terminator("--")` caused problems with an argument with `.last(true)` ## [4.5.56] - 2026-01-29 ### Fixes - On conflict error, don't show conflicting arguments in the usage ## [4.5.55] - 2026-01-27 ### Fixes - Fix inconsistency in precedence between positionals with a `value_terminator("--")` and escapes (`--`) where `./foo -- bar` means the first arg is empty, rather than escaping future args ## [4.5.54] - 2026-01-02 ### Fixes - *(help)* Move `[default]` to its own paragraph when `PossibleValue::help` is present in `--help` ## [4.5.53] - 2025-11-19 ### Features - Add `default_values_if`, `default_values_ifs` ## [4.5.52] - 2025-11-17 ### Fixes - Don't panic when `args_conflicts_with_subcommands` conflicts with an `ArgGroup` ## [4.5.51] - 2025-10-29 ### Fixes - *(help)* Correctly calculate padding for short flags that take a value - *(help)* Don't panic on short flags using `ArgAction::Count` ## [4.5.50] - 2025-10-20 ### Features - Accept `Cow` where `String` and `&str` are accepted ## [4.5.49] - 2025-10-13 ### Fixes - *(help)* Correctly wrap when ANSI escape codes are present ## [4.5.48] - 2025-09-19 ### Documentation - Add a new CLI Concepts document as another way of framing clap - Expand the `typed_derive` cookbook entry ## [4.5.47] - 2025-09-02 ### Features - Added `impl FromArgMatches for ()` - Added `impl Args for ()` - Added `impl Subcommand for ()` - Added `impl FromArgMatches for Infallible` - Added `impl Subcommand for Infallible` ### Fixes - *(derive)* Update runtime error text to match `clap` ## [4.5.46] - 2025-08-26 ### Features - Expose `StyledStr::push_str` ## [4.5.45] - 2025-08-12 ### Fixes - *(unstable-v5)* `ValueEnum` variants now use the full doc comment, not summary, for `PossibleValue::help` ## [4.5.44] - 2025-08-11 ### Features - Add `Command::mut_subcommands` ## [4.5.43] - 2025-08-06 ### Fixes - *(help)* In long help, list Possible Values before defaults, rather than after, for a more consistent look ## [4.5.42] - 2025-07-30 ### Fixes - Include subcommand visible long aliases in `--help` ## [4.5.41] - 2025-07-09 ### Features - Add `Styles::context` and `Styles::context_value` to customize the styling of `[default: value]` like notes in the `--help` ## [4.5.40] - 2025-06-09 ### Features - Support quoted ids in `arg!()` macro (e.g. `arg!("check-config": ...)`) ## [4.5.39] - 2025-05-27 ### Fixes - *(help)* Show short flag aliases before long - *(help)* Merge the short and long flag alias lists ## [4.5.38] - 2025-05-11 ### Fixes - *(help)* When showing aliases, include leading `--` or `-` ## [4.5.37] - 2025-04-18 ### Features - Added `ArgMatches::try_clear_id()` ## [4.5.36] - 2025-04-11 ### Fixes - *(help)* Revert 4.5.35's "Don't leave space for shorts if there are none" for now ## [4.5.35] - 2025-04-01 ### Fixes - *(help)* Align positionals and flags when put in the same `help_heading` - *(help)* Don't leave space for shorts if there are none ## [4.5.34] - 2025-03-27 ### Fixes - *(help)* Don't add extra blank lines with `flatten_help(true)` and subcommands without arguments ## [4.5.33] - 2025-03-26 ### Fixes - *(error)* When showing the usage of a suggestion for an unknown argument, don't show the group ## [4.5.32] - 2025-03-10 ### Features - Add `Error::remove` ### Documentation - *(cookbook)* Switch from `humantime` to `jiff` - *(tutorial)* Better cover required vs optional ### Internal - Update `pulldown-cmark` ## [4.5.31] - 2025-02-24 ### Features - Add `ValueParserFactory` for `Saturating` ## [4.5.30] - 2025-02-17 ### Fixes - *(assert)* Allow `num_args(0..=1)` to be used with `SetTrue` - *(assert)* Clean up rendering of `takes_values` assertions ## [4.5.29] - 2025-02-11 ### Fixes - Change `ArgMatches::args_present` so not-present flags are considered not-present (matching the documentation) ## [4.5.28] - 2025-02-03 ### Features - *(derive)* Unstable support for full markdown syntax for doc comments, enabled with `unstable-markdown` ## [4.5.27] - 2025-01-20 ### Documentation - Iterate on tutorials and reference based on feedback ## [4.5.26] - 2025-01-09 ### Fixes - *(error)* Reduce binary size with the `suggestions` feature ## [4.5.25] - 2025-01-09 ### Fixes - *(help)* Reduce binary size ## [4.5.24] - 2025-01-07 ### Fixes - *(parser)* Correctly handle defaults with `ignore_errors(true)` and when a suggestion is provided for an unknown argument ## [4.5.23] - 2024-12-05 ### Fixes - *(parser)* When check `allow_negative_numbers`, allow `E` again ## [4.5.22] - 2024-12-03 ### Fixes - *(assert)* Catch bugs with arguments requiring themself ## [4.5.21] - 2024-11-13 ### Fixes - *(parser)* Ensure defaults are filled in on error with `ignore_errors(true)` ## [4.5.20] - 2024-10-08 ### Features - *(unstable)* Add `CommandExt` ## [4.5.19] - 2024-10-01 ### Internal - Update dependencies ## [4.5.18] - 2024-09-20 ### Features - *(builder)* Expose `Arg::get_display_order` and `Command::get_display_order` ## [4.5.17] - 2024-09-04 ### Fixes - *(help)* Style required argument groups - *(derive)* Improve error messages when unsupported fields are used ## [4.5.16] - 2024-08-15 ### Fixes - *(derive)* Improve error messages when `derive` feature is missing ## [4.5.15] - 2024-08-10 ### Compatiblity - *(unstable-ext)* `Arg::remove` changed return types ### Fixes - *(unstable-ext)* Make `Arg::remove` return the removed item ## [4.5.14] - 2024-08-08 ### Features - *(unstable-ext)* Added `Arg::add` for attaching arbitrary state, like completion hints, to `Arg` without `Arg` knowing about it ## [4.5.13] - 2024-07-31 ### Fixes - *(derive)* Improve error message when `#[flatten]`ing an optional `#[group(skip)]` - *(help)* Properly wrap long subcommand descriptions in help ## [4.5.12] - 2024-07-31 ## [4.5.11] - 2024-07-25 ## [4.5.10] - 2024-07-23 ## [4.5.9] - 2024-07-09 ### Fixes - *(error)* When defining a custom help flag, be sure to suggest it like we do the built-in one ## [4.5.8] - 2024-06-28 ### Fixes - Reduce extra flushes ## [4.5.7] - 2024-06-10 ### Fixes - Clean up error message when too few arguments for `num_args` ## [4.5.6] - 2024-06-06 ## [4.5.5] - 2024-06-06 ### Fixes - Allow `exclusive` to override `required_unless_present`, `required_unless_present_any`, `required_unless_present_all` ## [4.5.4] - 2024-03-25 ### Fixes - *(derive)* Allow non-literal `#[arg(id)]` attributes again ## [4.5.3] - 2024-03-15 ### Internal - *(derive)* Update `heck` ## [4.5.2] - 2024-03-06 ### Fixes - *(macros)* Silence a warning ## [4.5.1] - 2024-02-16 ### Fixes - *(error)* Include suggestion to add `--` even if there is a "did you mean" so long as `last` or `trailing_var_arg` is used ## [4.5.0] - 2024-02-08 ### Compatibility - Update MSRV to 1.74 ## [4.4.18] - 2024-01-16 ### Fixes - *(error)* When lacking `usage` feature, ensure the list of required arguments is unique ## [4.4.17] - 2024-01-15 ### Fixes - Fix `panic!` when mixing `args_conflicts_with_subcommands` with `ArgGroup` (which is implicit with `derive`) introduced in 4.4.15 ## [4.4.16] - 2024-01-12 ### Fixes - Ensure invalid escape sequences in user-defined strings are correctly stripped when terminal doesn't support color ## [4.4.15] - 2024-01-11 ### Fixes - Improve error for `args_conflicts_with_subcommands` - Ensure we error for `args_conflicts_with_subcommands` when using subcommand short and long flags ## [4.4.14] - 2024-01-08 ### Documentation - Fix `find` cookbook entry to allow repeats of flags/options ### Features - Allow `num_args(0)` on options which allows making them emulate being a flag for position-tracking flags ## [4.4.13] - 2024-01-04 ### Documentation - Fix link to structopt migration guide ## [4.4.12] - 2023-12-28 ### Performance - Only ask `TypedValueParser` for possible values if needed ## [4.4.11] - 2023-12-04 ### Features - Add `Command::mut_group` ## [4.4.10] - 2023-11-28 ### Documentation - Link out to changelog - Cross link derive's attribute reference to derive tutorial ## [4.4.9] - 2023-11-27 ### Fixes - *(help)* Show correct `Command::about` under flattened headings - *(help)* Respect `hide` when flattening subcommands ## [4.4.8] - 2023-11-10 ### Features - Add `Command::flatten_help` to allow `git stash -h` like help for subcommands ## [4.4.7] - 2023-10-24 ### Performance - Reduced code size ## [4.4.6] - 2023-09-28 ### Internal - Upgrade `anstream` ## [4.4.5] - 2023-09-25 ### Fixes - *(parser)* When inferring subcommand `name` or `long_flag`, allow ambiguous-looking matches that unambiguously map back to the same command - *(parser)* When inferring subcommand `long_flag`, don't panic - *(assert)* Clarify what action is causing a positional that doesn't set values which is especially useful for derive users ## [4.4.4] - 2023-09-18 ### Internal - Update `terminal_size` to 0.3 ## [4.4.3] - 2023-09-12 ### Documentation - *(derive)* Clarify use of attributes within the tutorial - Split sections in the builder and derive tutorials into separate modules ## [4.4.2] - 2023-08-31 ### Performance - Improve build times by removing `once_cell` dependency ## [4.4.1] - 2023-08-28 ### Features - Stabilize `Command::styles` ## [4.4.0] - 2023-08-24 ### compatibility - update msrv to 1.70.0 ## [4.3.24] - 2023-08-23 ### Fixes - Ensure column padding is preserved in `--help` with custom templates ## [4.3.23] - 2023-08-18 ### Fixes - Fixed `UnknownArgumentValueParser` to not error on flag's absence ## [4.3.22] - 2023-08-17 ### Features - Add `UnknownArgumentValueParser` for injecting errors for improving the experience with errors ## [4.3.21] - 2023-08-08 ### Features - Expose `TryMapValueParser` so the type can be named ## [4.3.20] - 2023-08-08 ### Features - `Command::mut_args` for modifying all arguments en masse ## [4.3.19] - 2023-07-21 ### Fixes - *(parse)* Respect `value_terminator` even in the presence of later multiple-value positional arguments ## [4.3.18] - 2023-07-21 ### Fixes - *(parse)* Suggest `--` in fewer places where it won't work ## [4.3.17] - 2023-07-19 ### Fixes - *(help)* Address a regression in wrapping `PossibleValue` descriptions in `--help` ## [4.3.16] - 2023-07-18 ### Fixes - Don't assert when stateful value parsers fail on defaults (e.g. checking if a path exists) ## [4.3.15] - 2023-07-18 ### Features - *(unstable-styles)* Re-export `anstyle` ### Documentation - *(unstable-styles)* Provide more examples ## [4.3.14] - 2023-07-17 ### Features - `ArgAction::HelpShort` and `ArgAction::HelpLong` for explicitly specifying which style of help to display ### Fixes - Skip `[OPTIONS]` in usage if a help or version `ArgAction` is used ## [4.3.13] - 2023-07-17 ## [4.3.12] - 2023-07-14 ### Fixes - *(derive)* Don't error on enum variant field attributes ## [4.3.11] - 2023-07-05 ### Features - *(derive)* Support fields wrapped in `num::Wrapping`, `Box`, or `Arc` - *(derive)* Support `Box`, `Box`, and `Box` ## [4.3.10] - 2023-06-30 ### Performance - Drop a dependency, reducing binary size by 1.3 KiB ## [4.3.9] - 2023-06-28 ### Fixes - `Command::ignore_errors` no longer masks help/version ## [4.3.8] - 2023-06-23 ### Fixes - Error on ambiguity with `infer_long_arg`, rather than arbitrarily picking one, matching the documentation and subcommand's behavior ## [4.3.7] - 2023-06-23 ### Documentation - Further clarify magic behavior in derive tutorial - Further clarify derive API's relationship to builder within the tutorial ## [4.3.6] - 2023-06-23 ### Documentation - Suggest `clio` ## [4.3.5] - 2023-06-20 - `ColorChoice::possible_values` is added to simplify things for builder users ### Fixes - `ColorChoice::to_possible_value` no longer includes descriptions, encouraging shorter help where possible ## [4.3.4] - 2023-06-14 ### Features - Add `Error::exit_code` ## [4.3.3] - 2023-06-09 ### Features - `Command::defer` for delayed initialization of subcommands to reduce startup times of large applications like deno ## [4.3.2] - 2023-06-05 ### Fixes - *(derive)* Don't produce `unused_equalifications` warnings when someone brings a clap type into scope ## [4.3.1] - 2023-06-02 ### Performance - *(derive)* Reduce the amount of generated code ## [4.3.0] - 2023-05-19 ### Fixes - *(assert)* Allow multiple, value-terminated, positional arguments - *(assert)* Clear up language on `last` assertion - *(parser)* Correctly assign values to arguments when using multiple, value-termianted, positional arguments - *(parser)* Ensure `value_terminator` has higher precedence than `allow_hyphen_values` - *(help)* Only use next-line-help on subcommand list when explicitly specified, not just with `--help` - *(help)* Correctly align possible values list - *(help)* Don't waste code, vertical space in moving possible value descriptions to next line ## [4.2.7] - 2023-05-02 ### Fixes - Correctly track remaining length for iterators provided by `ArgMatches` ## [4.2.6] - 2023-05-02 ### Features - `impl Eq for clap_builder::util::AnyValueId` ## [4.2.5] - 2023-04-27 ### Fixes - Improve panic when a group requires a non-existent ID ## [4.2.4] - 2023-04-19 ### Documentation - Corrected docs for `Command::style` ## [4.2.3] - 2023-04-18 ### Features - `Command::styles` for theming help/errors (behind `unstable-styles`) ## [4.2.2] - 2023-04-13 ### Internal - Update dependencies ## [4.2.1] - 2023-03-28 ### Fixes - Don't highlight uninteresting parts of the error message ## [4.2.0] - 2023-03-28 ### Compatibility - Removed the languishing `unstable-replace` feature (open to discussion at [#2836](https://github.com/clap-rs/clap/issues/2836)) - Removed the stablized `unstable-grouped` feature ### Features - Allow any `StyledStr` to accept text styled with ANSI escape codes - Respect `CLICOLOR`, `CLICOLOR_FORCE` ### Fixes - Lighten the tone for "unexpected argument" errors (open to discussion at [#4638](https://github.com/clap-rs/clap/issues/4638)) ## [4.1.14] - 2023-03-28 ### Features - *(derive)* `#[group]` raw attribute support ### Performance - *(derive)* `clap_builder` was pulled out of `clap` so it could build in parallel to `clap_derive` - `os_str_bytes` dependency was removed for faster builds and smaller binaries ## [4.1.13] - 2023-03-18 ### Performance - Reduce repeated alloc calls when building a `Command` - Reduce duplicate dependencies for faster builds ## [4.1.12] - 2023-03-18 ### Internal - *(derive)* Update to `syn` v2 ### Performance - *(derive)* Faster build times by dropping `proc-macro-error` dependency ## [4.1.11] - 2023-03-17 ### Internal - Update `bitflags` ## [4.1.10] - 2023-03-17 ### Fixes - *(help)* On Windows, avoid underlined text artifacts ## [4.1.9] - 2023-03-16 ### Fixes - *(assert)* Improve the assert when using the wrong action with `get_count` / `get_flag` ## [4.1.8] - 2023-02-27 ### Fixes - *(derive)* Don't `deny` lints on the users behalf ## [4.1.7] - 2023-02-27 ### Fixes - *(derive)* Hide some nightly clippy warnings ## [4.1.6] - 2023-02-15 ### Fixes - *(help)* Don't show long help for `--help` just because hidden possible values include a description ## [4.1.5] - 2023-02-15 ### Fixes - *(help)* Don't show long help for `--help` just because a hidden arg has a possible value with a description ## [4.1.4] - 2023-01-24 ### Fixes - *(help)* Respect `disable_colored_help` when using `arg_required_else_help` ### Performance - Speed up compiling `arg!` macro ## [4.1.3] - 2023-01-23 ### Fixes - *(error)* Improve suggested flag/value/subcommand when two share a long preifx - *(error)* When suggesting one of several subcommands, use the plural `subcommands`, rather than `subcommand` ## [4.1.2] - 2023-01-23 ### Fixes - In documentation, refer to `get_flag`, rather than `get_one::` ## [4.1.1] - 2023-01-14 ### Fixes - *(error)* Small softening attempt for "unexpected argument" error ## [4.1.0] - 2023-01-13 ### Compatibility MSRV changed to 1.64.0 For apps with custom `--help` and `--version` flags: - Descriptions for `--help` and `--version` changed When apps have errors imitating clap's error style: - Error message style was changed, including - Moving away from "did you mean" to tips - Leading letter is lower case - "For more" added some punctuation ### Features - `ArgMatches::get_occurrences` support for argument values to be grouped by their occurrence ### Fixes - *(derive)* Allow `upgrade_from` when arguments / subcommands are explicitly marked as required - *(help)* Try be more clearer and succinct with `--help` and `--version` (also helps with overflow) - *(error)* Try to be more clearer and succinct with error messages - *(error)* Officially adopt [an error style guide](https://rustc-dev-guide.rust-lang.org/diagnostics.html#suggestion-style-guide) ## [4.0.32] - 2022-12-22 ### Fixes - *(parser)* When overriding `required(true)`, consider args that conflict with its group ## [4.0.31] - 2022-12-22 ### Performance - Speed up parsing when a lot of different flags are present (100 unique flags) ## [4.0.30] - 2022-12-21 ### Fixes - *(error)* Improve error for `args_conflicts_with_subcommand` ## [4.0.29] - 2022-11-29 ## [4.0.28] - 2022-11-29 ### Fixes - Fix wasm support which was broken in 4.0.27 ## [4.0.27] - 2022-11-24 ### Features - Have `Arg::value_parser` accept `Vec>` - Implement `Display` and `FromStr` for `ColorChoice` ### Fixes - Remove soundness issue by switching from `atty` to `is-terminal` ## [4.0.26] - 2022-11-16 ### Fixes - *(error)* Fix typos in `ContextKind::as_str` ## [4.0.25] - 2022-11-15 ### Features - *(error)* Report available subcommands when required subcommand is missing ## [4.0.24] - 2022-11-14 ### Fixes - Avoid panic when printing an argument that isn't built ## [4.0.23] - 2022-11-11 ### Fixes - Don't panic on reporting invalid-long errors when followed by invalid UTF8 - *(help)* Clarified argument to `help` subcommand ## [4.0.22] - 2022-11-07 ### Fixes - *(help)* Don't overflow into next-line-help early due to stale (pre-v4) padding calculations ## [4.0.21] - 2022-11-07 ### Features - *(derive)* `long_about` and `long_help` attributes, without a value, force using doc comment (before it wouldn't be set if there wasn't anything different than the short help) ## [4.0.20] - 2022-11-07 ### Fixes - *(derive)* Allow defaulted value parser for '()' fields ## [4.0.19] - 2022-11-04 ### Features - `ColorChoice` now implements `ValueEnum` ## [4.0.18] - 2022-10-20 ### Fixes - *(derive)* Allow `#[command(skip)]` to also work with enum variants with a value ## [4.0.17] - 2022-10-18 ### Fixes - Allow using `Arg::last(true)` with `Arg::value_hint(ValueHint::CommandWithArguments)` ## [4.0.16] - 2022-10-18 ### Fixes - `Arg::exclusive(true)` should not be exclusive with the argument's own `ArgGroup` ## [4.0.15] - 2022-10-13 ### Fixes - *(error)* Don't suggest `--` when it doesn't help - *(error)* Be more consistent in quoting, punctuation, and indentation in errors ## [4.0.14] - 2022-10-12 ### Fixes - Only put `ArgGroup` in `ArgMatches` when explicitly specified, fixing derives handling of option-flattened fields (#4375) ## [4.0.13] - 2022-10-11 ### Features - *(derive)* Allow `()` for fields to mean "don't read" (#4371) ## [4.0.12] - 2022-10-10 ### Features - Added `TypedValueParser::try_map` for when adapting an existing `TypedValueParser` can fail - *(error)* Create errors like clap with `Error::new`, `Error::with_cmd`, and `Error::insert` ## [4.0.11] - 2022-10-09 ### Fixes - *(help)* Fix wrapping calculations with ANSI escape codes ## [4.0.10] - 2022-10-05 ### Features - *(derive)* Support `#[arg(flatten)]` on `Option` types (#4211, #4350) ## [4.0.9] - 2022-10-03 ### Fixes - *(derive)* Process doc comments for `#[command(subcommand)]` like in clap v3 ## [4.0.8] - 2022-10-01 ### Fixes - *(derive)* Remove a low-value assert preventing defaulting `Help` and `Version` actions ## [4.0.7] - 2022-09-30 ### Features - *(derive)* Populate implicit ArgGroup (#3165) ### Fixes - *(derive)* Support `#[group(skip)]` on `Parser` derive - *(derive)* Tell users about implicit arg groups when running into group name conflicts - *(error)* Don't report unrelated groups in conflict or requires errors ## [4.0.6] - 2022-09-30 ### Features - *(derive)* Support `#[group(skip)]` (#4279, #4301) ## [4.0.5] - 2022-09-30 ## [4.0.4] - 2022-09-29 ### Fixes - *(error)* Specialize the self-conflict error to look like clap v3 ## [4.0.3] - 2022-09-29 ### Fixes - *(error)* Quote literals consistently - *(error)* Stylize escape (`--`) suggestions - *(error)* Format help flag as a literal ## [4.0.2] - 2022-09-28 ### Fixes - *(parser)* `SetFalse` should conflict with itself like `SetTrue` and `Set` - *(parser)* Allow one-off overrides ## [4.0.1] - 2022-09-28 ### Fixes - *(derive)* Ensure `#[clap(...)]` attribute still works ## [4.0.0] - 2022-09-28 ### Highlights **`Arg::num_args(range)`** Clap has had several ways for controlling how many values will be captured without always being clear on how they interacted, including - `Arg::multiple_values(true)` - `Arg::number_of_values(4)` - `Arg::min_values(2)` - `Arg::max_values(20)` - `Arg::takes_value(true)` These have now all been collapsed into `Arg::num_args` which accepts both single values and ranges of values. `num_args` controls how many raw arguments on the command line will be captured as values per occurrence and independent of value delimiters. See [Issue 2688](https://github.com/clap-rs/clap/issues/2688) for more background. **Polishing Help** Clap strives to give a polished CLI experience out of the box with little ceremony. With some feedback that has accumulated over time, we took this release as an opportunity to re-evaluate our `--help` output to make sure it is meeting that goal. In doing this evaluation, we wanted to keep in mind: - Whether other CLIs had ideas that make sense to apply - Providing an experience that fits within the rest of applications and works across all shells Before: ``` git A fictional versioning CLI USAGE: git OPTIONS: -h, --help Print help information SUBCOMMANDS: add adds things clone Clones repos help Print this message or the help of the given subcommand(s) push pushes things stash ``` After: ``` A fictional versioning CLI Usage: git Commands: clone Clones repos push pushes things add adds things stash help Print this message or the help of the given subcommand(s) Options: -h, --help Print help information ``` - name/version header was removed because we couldn't justify the space it occupied when - Usage already includes the name - `--version` is available for showing the same thing (if the program has a version set) - Usage was dropped to one line to save space - Focus is put on the subcommands - Headings are now Title case - The more general term "command" is used rather than being explicit about being "subcommands" - The output is more dense with the expectation that it won't affect legibility but will allow more content - We've moved to a more neutral palette for highlighting elements (not highlighted above) In talking to users, we found some that liked clap's `man`-like experience. When deviating from this, we are making the assumption that those are more power users and that the majority of users wouldn't look as favorably on being consistent with `man`. See [Issue 4132](https://github.com/clap-rs/clap/issues/4132) for more background. **More Dynamicism** Clap's API has focused on `&str` for performance but this can make dealing with owned data difficult, like `#[arg(default_value_t)]` generating a String from the default value. Additionally, to avoid `ArgMatches` from borrowing (and for some features we decided to forgo), clap took the `&str` argument IDs and hashed them. This prevented us from providing a usable API for iterating over existing arguments. Now clap has switched to a string newtype that gives us the flexibility to decide whether to use `&'static str`, `Cow<'static, str>` for fast dynamic behavior, or `Box` for dynamic behavior with small binary size. As an extension of that work, you can now call `ArgMatches::ids` to iterate over the arguments and groups that were found when parsing. The newtype `Id` was used to prevent some classes of bugs and to make it easier to understand when opaque Ids are used vs user-visible strings. **Clearing Out Deprecations** Instead of doing all development on clap 4.0.0, we implemented a lot of new features during clap 3's development, deprecating the old API while introducing the new API, including: - Replacing the implicit behavior for args when parsing them with `ArgAction` - Replacing various one-off forms of value validation with the `ValueParser` API - Allowing derives to automatically do the right thing for `PathBuf` (allowing invalid UTF-8) - Replacing `AppSettings` and `ArgSettings` enums with getters/setters - Clarifying terms and making them more consistent ### Migrating Steps: 0. [Upgrade to v3](https://github.com/clap-rs/clap/blob/v3-master/CHANGELOG.md#migrating) if you haven't already 1. Add CLI tests (including example below), `-h` and `--help` output at a minimum (recommendation: [trycmd](https://docs.rs/trycmd/) for snapshot testing) 2. *If using Builder API*: Explicitly set the `arg.action(ArgAction::...)` on each argument (`StoreValue` for options and `IncOccurrences` for flags) 3. Run `cargo check --features clap/deprecated` and resolve all deprecation warnings 4. Upgrade to v4 5. Update feature flags - *If `default-features = false`*, run `cargo add clap -F help,usage,error-context` - Run `cargo add clap -F wrap_help` unless you want to hard code line wraps 6. Resolve compiler errors 7. Resolve behavior changes (see "subtle changes" under BREAKING CHANGES) 8. *At your leisure:* resolve new deprecation notices Example test (derive): ```rust #[derive(clap::Parser)] struct Cli { ... } #[test] fn verify_cli() { use clap::CommandFactory; Cli::command().debug_assert() } ``` Example test (builder): ```rust fn cli() -> clap::Command { ... } #[test] fn verify_cli() { cli().debug_assert(); } ``` Note: the idiomatic / recommended way of specifying different types of args in the Builder API has changed: Before ```rust .arg(Arg::new("flag").long("flag")) # --flag .arg(Arg::new("option").long("option").takes_value(true)) # --option