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, and perl6 are accepted spellings.

fn parse_toolchain_spec(spec: &str, flag: &str) -> Result<Toolchain, UsageError>

Parse name/version.

system and SYSTEM, and the same names with a trailing slash, are the SYSTEM toolchain. EasyBuild’s SYSTEM constant is {'name': 'system', 'version': 'system'} (easyconfig/constants.py in framework 5.4.1). An empty version is that same toolchain: the framework treats the name system as SYSTEM regardless of version. system/system stays 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/version in spec, or the split name and version fields.

default_name fills a missing name with foss. Bump does not, on the CLI or on MCP. An empty name is a usage error, not a missing name, so it does not become foss. An empty version is kept: a SYSTEM recipe has one. flag is --toolchain on the CLI and toolchain on MCP. Passing spec together with a split field is a usage error.

fn usage(message: impl Display) -> anyhow::Error

Wrap a usage rejection so ? and anyhow context 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