Skip to main content

Crate appcore_args

Crate appcore_args 

Source
Expand description

§appcore-args

Português | Français

Dependency-free, cross-platform command-line parsing, help, validation and shell completion primitives for AppCore executables.

appcore-args provides nested commands, inherited options, typed and bounded arguments, deterministic errors, generated help, completion candidates and dynamic completion scripts for Bash, Zsh, Fish and PowerShell. It executes no Runtime behavior and uses no unsafe code.

use appcore_args::{ArgumentSpec, CliParser, CliSpec, CommandSpec, OptionSpec, RawArgs};

let spec = CliSpec::new("demo")
    .option(OptionSpec::flag("verbose").short('v'))
    .command(CommandSpec::new("run").argument(
        ArgumentSpec::new("mode").required(true).possible_value("safe"),
    ));
let parsed = CliParser::new(&spec)
    .parse(&RawArgs::parse(["run", "safe", "-v"])? )?;

assert_eq!(parsed.command_path(), &["run"]);
assert!(parsed.has_flag("verbose"));

See the English guide and examples. API documentation is available on docs.rs.

License: MIT.

Structs§

ArgLimits
ArgumentSpec
CliError
CliParser
CliSpec
CommandSpec
CompletionCandidate
CompletionEngine
CompletionRequest
HelpRenderer
OptionSpec
ParsedCli
ParsedOption
RawArgs
ShellScriptError
SpecError

Enums§

CliErrorKind
CompletionKind
Shell
ValueMode
ValueType

Functions§

render_dynamic_completion_script