-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
A-helpArea: documentation, including docs.rs, readme, examples, etc...Area: documentation, including docs.rs, readme, examples, etc...C-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectationsS-waiting-on-designStatus: Waiting on user-facing design to be resolved before implementingStatus: Waiting on user-facing design to be resolved before implementing
Description
Make it easy for developers to support translations of their projects.
Current steps:
- Run
cargo add clap -F string - If using derive API
- Replace field names being used as value names via
#[arg(value_name = ...)]
- Replace field names being used as value names via
- If using subcommands:
- Replace
Commands:header with a localized value viaCommand::subcommand_help_heading - Replace
<COMMAND>value name with a localized value viaCommand::subcommand_value_name
- Replace
- Replace
ArgumentsandOptions:headers with localized values viaCommand::next_help_headingand/orArg::help_heading - Disable the built-in flags (
Command::disable_help_flag(false)andCommand::disable_version_flag(false)) and provide your own versions (withArgAction::Help,ArgAction::Version) with localizedArg::help - Replace hard coded strings in help template (e.g.
Usage) with a localized version viaCommand::help_template- Requires styling
Usagemanually
- Requires styling
- Remove hard coded
[]messages with Arg::hide_default_value, Arg::hide_possible_values, Arg::hide_env - Fork
clap::error::RichFormatter, replacing any hard coded strings with localized values. UseError::applyto swap the formatter (e.g. useParser::try_parseto get the error, callapply, and thenerr.exit()) - Replace in usages the collapsed optional named arguments placeholder
[OPTIONS]by providing a custom usage withCommand::override_usage
Unresolved:
- Getting the suggestion to run
--helpin errors, see How to make custom -h achieve the same effect as default -h #5409 - Manually writing usage and losing out on the adaptive usage in errors
[aliases],[possible values],[default],[env], andPossible values:in help
Past examples:
schneiderfelipe, OriginCode, Zxilly, wangzishi, Niederb and 11 more
Metadata
Metadata
Assignees
Labels
A-helpArea: documentation, including docs.rs, readme, examples, etc...Area: documentation, including docs.rs, readme, examples, etc...C-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectationsS-waiting-on-designStatus: Waiting on user-facing design to be resolved before implementingStatus: Waiting on user-facing design to be resolved before implementing