mod cli_parse¶
- module cli_parse¶
Shared command-line parsing for the CLI and the MCP tools.
One usage error, one toolchain parser, and one foreign-format parser. The CLI maps the error to exit status 2. MCP maps it to a tool error.
Functions
- fn parse_foreign_format(value: &str, flag: &str) -> Result<Option<ForeignFormat>, UsageError>¶
auto, or one foreign recipe language.conda,crates,crates.io,lua, andperl6are accepted spellings.
- fn parse_toolchain_spec(spec: &str, flag: &str) -> Result<Toolchain, UsageError>¶
Parse
name/version.systemandSYSTEM, and the same names with a trailing slash, are the SYSTEM toolchain. EasyBuild’s SYSTEM constant is{'name': 'system', 'version': 'system'}(easyconfig/constants.pyin framework 5.4.1). An empty version is that same toolchain: the framework treats the namesystemas SYSTEM regardless of version.system/systemstays a name and a version, which is the constant’s own spelling.
- fn resolve_toolchain(name: Option<&str>, version: Option<&str>, spec: Option<&str>, default_name: bool, flag: &str) -> Result<Toolchain, UsageError>¶
name/versioninspec, or the split name and version fields.default_namefills a missing name withfoss. Bump does not, on the CLI or on MCP. An empty name is a usage error, not a missing name, so it does not becomefoss. An empty version is kept: a SYSTEM recipe has one.flagis--toolchainon the CLI andtoolchainon MCP. Passingspectogether with a split field is a usage error.
- fn usage(message: impl Display) -> anyhow::Error¶
Wrap a usage rejection so
?andanyhowcontext keep it in the chain.
Structs and Unions
- struct UsageError¶
The command line was rejected before the work started.
Exit status is 2, the same status clap uses for a missing flag. A missing file, a parse failure, or a check that failed is status 1 instead.
Implementations
- impl UsageError¶
Functions
- fn new(message: impl Display) -> Self¶
A rejection whose text is
message.
Traits implemented
- impl Display for UsageError¶
- impl Error for UsageError¶