Expand description
XaCLI - A modern, developer-friendly CLI framework for Rust
This crate serves as a facade for the xacli ecosystem, re-exporting functionality from:
xacli-core: Core command parsing and executionxacli-components: Interactive terminal components (feature:components)xacli-derive: Derive macros for CLI apps (feature:derive)xacli-testing: Testing utilities (feature:testing)
§Example
ⓘ
use xacli::{App, Command, Arg};
App::new("myapp", "1.0.0")
.command(
Command::new("greet")
.description("Greet someone")
.run(Box::new(|ctx| {
println!("Hello!");
Ok(())
}))
)
.execute()?;§Features
components: Interactive terminal components (input, select, confirm, etc.)derive: Derive macros (#[derive(App)],#[derive(Command)])testing: Testing utilities for CLI appscli: CLI binary tooling (includesderiveandtesting)
§Installation
As a library:
cargo add xacli
cargo add xacli --features derive
cargo add xacli --features componentsAs a CLI tool:
cargo install xacli --features cliModules§
- prelude
- Prelude for convenient imports
Structs§
- App
- AppContext
- Standard context implementation using stdin/stdout/stderr
- AppInfo
- Arg
- ArgInfo
- Command
- Command
Info - Component
Info - Context
Info - Context metadata
- Output
- Parsed
- Parsed command-line arguments result
Enums§
- ArgKind
- Kind of argument (positional, flag, or option)
- ArgType
- Argument value types
- Error
- Errors that can occur during command parsing and execution
- Input
Event - Represents an event.
- Input
Value - Output
Command - 完整的终端控制命令枚举
Constants§
Traits§
- Completer
- Provides dynamic completion suggestions
- Context
- Input
Component - Interactive component that runs with a context
- Logger
- Output
Component - Interactive component that produces output
- Prompter
- Prompts user for input interactively
- Read
Event - Validator
- Validates an argument value
Type Aliases§
- Result
- Result type alias for XaCLI operations