1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! # argot
//!
//! An agent-first command interface framework for Rust.
//!
//! argot makes it easy to define structured CLI commands that are equally
//! useful for human operators and AI agents. Every command carries rich
//! metadata — summaries, descriptions, typed arguments, flags, examples, and
//! best-practice guidance — that can be serialized to JSON or rendered as
//! Markdown for consumption by an LLM tool-call layer.
//!
//! ## Architecture
//!
//! The library is built around five cooperating layers:
//!
//! 1. **[`model`]** — the data model: [`Command`], [`Argument`], [`Flag`],
//! [`Example`], and their builders.
//! 2. **[`resolver`]** — maps a raw string token to a [`Command`] via exact →
//! prefix → ambiguous resolution.
//! 3. **[`parser`]** — tokenizes a raw `argv` slice, walks the subcommand tree
//! using the resolver, then binds flags and positional arguments.
//! 4. **[`query`]** — [`Registry`] is the central command store; it supports
//! lookup by canonical name, subcommand path, substring search, and fuzzy
//! search.
//! 5. **[`render`]** — three plain-text / Markdown renderers: [`render_help`],
//! [`render_subcommand_list`], and [`render_markdown`].
//!
//! A convenience [`cli`] module provides the [`Cli`] struct, which wires all
//! five layers together so you can go from `Vec<Command>` to a fully
//! functional CLI dispatch loop in a few lines.
//!
//! ## Quick Start
//!
//! ```no_run
//! use std::sync::Arc;
//! use argot_cmd::{Command, Flag, Registry, Parser, render_help};
//!
//! // 1. Build commands.
//! let cmd = Command::builder("deploy")
//! .summary("Deploy the application to an environment")
//! .flag(
//! Flag::builder("env")
//! .description("Target environment")
//! .takes_value()
//! .required()
//! .build()
//! .unwrap(),
//! )
//! .handler(Arc::new(|parsed| {
//! println!("deploying to {}", parsed.flags["env"]);
//! Ok(())
//! }))
//! .build()
//! .unwrap();
//!
//! // 2. Store in a registry.
//! let registry = Registry::new(vec![cmd]);
//!
//! // 3. Parse raw arguments.
//! let parser = Parser::new(registry.commands());
//! let parsed = parser.parse(&["deploy", "--env", "production"]).unwrap();
//!
//! // 4. Render help.
//! let help = render_help(parsed.command);
//! println!("{}", help);
//! ```
//!
//! ## Feature Flags
//!
//! | Feature | Description |
//! |-----------|-------------|
//! | `derive` | Enables the `#[derive(ArgotCommand)]` proc-macro from `argot-cmd-derive`. |
//! | `fuzzy` | Enables [`Registry::fuzzy_search`] via the `fuzzy-matcher` crate. |
//! | `mcp` | Enables the MCP stdio transport server ([`transport`]). |
//!
//! ## Modules
//!
//! - [`cli`] — high-level [`Cli`] entry point
//! - [`model`] — data model and builders
//! - [`resolver`] — string-to-command resolution
//! - [`parser`] — `argv` parsing
//! - [`query`] — command registry and search
//! - [`render`] — human-readable and Markdown output
pub use ;
pub use ;
pub use Middleware;
pub use ;
pub use AsyncHandlerFn;
pub use ;
pub use ;
pub use ;
pub use ;
/// Trait implemented by types annotated with `#[derive(ArgotCommand)]`.
///
/// Call `T::command()` to obtain a fully-built [`Command`] from the struct's
/// `#[argot(...)]` attributes.
///
/// # Examples
///
/// ```
/// # #[cfg(feature = "derive")] {
/// use argot_cmd::ArgotCommand;
///
/// #[derive(argot_cmd::ArgotCommand)]
/// #[argot(summary = "Greet the world")]
/// struct Greet;
///
/// let cmd = Greet::command();
/// assert_eq!(cmd.canonical, "greet");
/// # }
/// ```
pub use ArgotCommand;
/// MCP (Model Context Protocol) stdio transport server.
///
/// Enable with the `mcp` feature flag. Exposes the command registry as MCP
/// tools over a newline-delimited JSON-RPC 2.0 stream.
pub use McpServer;