mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-27 08:00:17 +00:00
Improve --help: add detailed about/examples/color, snapshot test (clo… (#371)
This commit is contained in:
+77
-8
@@ -37,14 +37,18 @@ pub use service::{ServiceCommand, run_service_command};
|
||||
pub use status::run_status_command;
|
||||
pub use tool::{ToolCommand, run_tool_command};
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use clap::{ColorChoice, Parser, Subcommand};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "ironclaw")]
|
||||
#[command(
|
||||
about = "Secure personal AI assistant that protects your data and expands its capabilities"
|
||||
)]
|
||||
#[command(
|
||||
long_about = "IronClaw is a secure AI assistant. Use 'ironclaw <subcommand> --help' for details.\nExamples:\n ironclaw run # Start the agent\n ironclaw config list # List configs"
|
||||
)]
|
||||
#[command(version)]
|
||||
#[command(color = ColorChoice::Auto)] // Enable auto-color for help (if the terminal supports it)
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Option<Command>,
|
||||
@@ -73,9 +77,17 @@ pub struct Cli {
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub enum Command {
|
||||
/// Run the agent (default if no subcommand given)
|
||||
#[command(
|
||||
about = "Run the AI agent",
|
||||
long_about = "Starts the IronClaw agent in default mode.\nExample: ironclaw run"
|
||||
)]
|
||||
Run,
|
||||
|
||||
/// Interactive onboarding wizard
|
||||
#[command(
|
||||
about = "Run interactive setup wizard",
|
||||
long_about = "Guides through initial configuration.\nExamples:\n ironclaw onboard --skip-auth # Skip auth step\n ironclaw onboard --channels-only # Reconfigure channels"
|
||||
)]
|
||||
Onboard {
|
||||
/// Skip authentication (use existing session)
|
||||
#[arg(long)]
|
||||
@@ -87,44 +99,85 @@ pub enum Command {
|
||||
},
|
||||
|
||||
/// Manage configuration settings
|
||||
#[command(subcommand)]
|
||||
#[command(
|
||||
subcommand,
|
||||
about = "Manage app configs",
|
||||
long_about = "Commands for listing, getting, and setting configurations.\nExample: ironclaw config list"
|
||||
)]
|
||||
Config(ConfigCommand),
|
||||
|
||||
/// Manage WASM tools
|
||||
#[command(subcommand)]
|
||||
#[command(
|
||||
subcommand,
|
||||
about = "Manage WASM tools",
|
||||
long_about = "Install, list, or remove WASM-based tools.\nExample: ironclaw tool install mytool.wasm"
|
||||
)]
|
||||
Tool(ToolCommand),
|
||||
|
||||
/// Browse and install extensions from the registry
|
||||
#[command(subcommand)]
|
||||
#[command(
|
||||
subcommand,
|
||||
about = "Browse/install extensions",
|
||||
long_about = "Interact with extension registry.\nExample: ironclaw registry list"
|
||||
)]
|
||||
Registry(RegistryCommand),
|
||||
|
||||
/// Manage MCP servers (hosted tool providers)
|
||||
#[command(subcommand)]
|
||||
#[command(
|
||||
subcommand,
|
||||
about = "Manage MCP servers",
|
||||
long_about = "Add, auth, list, or test MCP servers.\nExample: ironclaw mcp add notion https://mcp.notion.com"
|
||||
)]
|
||||
Mcp(McpCommand),
|
||||
|
||||
/// Query and manage workspace memory
|
||||
#[command(subcommand)]
|
||||
#[command(
|
||||
subcommand,
|
||||
about = "Manage workspace memory",
|
||||
long_about = "Search, read, or write to memory.\nExample: ironclaw memory search 'query'"
|
||||
)]
|
||||
Memory(MemoryCommand),
|
||||
|
||||
/// DM pairing (approve inbound requests from unknown senders)
|
||||
#[command(subcommand)]
|
||||
#[command(
|
||||
subcommand,
|
||||
about = "Manage DM pairing",
|
||||
long_about = "Approve or manage pairing requests.\nExamples:\n ironclaw pairing list telegram\n ironclaw pairing approve telegram ABC12345"
|
||||
)]
|
||||
Pairing(PairingCommand),
|
||||
|
||||
/// Manage OS service (launchd / systemd)
|
||||
#[command(subcommand)]
|
||||
#[command(
|
||||
subcommand,
|
||||
about = "Manage OS service",
|
||||
long_about = "Install, start, or stop service.\nExample: ironclaw service install"
|
||||
)]
|
||||
Service(ServiceCommand),
|
||||
|
||||
/// Probe external dependencies and validate configuration
|
||||
#[command(
|
||||
about = "Run diagnostics",
|
||||
long_about = "Checks dependencies and config validity.\nExample: ironclaw doctor"
|
||||
)]
|
||||
Doctor,
|
||||
|
||||
/// Show system health and diagnostics
|
||||
#[command(
|
||||
about = "Show system status",
|
||||
long_about = "Displays health and diagnostics info.\nExample: ironclaw status"
|
||||
)]
|
||||
Status,
|
||||
|
||||
/// Generate shell completion scripts
|
||||
#[command(
|
||||
about = "Generate completions",
|
||||
long_about = "Generates shell completion scripts.\nExample: ironclaw completion --shell bash > ironclaw.bash"
|
||||
)]
|
||||
Completion(Completion),
|
||||
|
||||
/// Run as a sandboxed worker inside a Docker container (internal use).
|
||||
/// This is invoked automatically by the orchestrator, not by users directly.
|
||||
#[command(hide = true)]
|
||||
Worker {
|
||||
/// Job ID to execute.
|
||||
#[arg(long)]
|
||||
@@ -141,6 +194,7 @@ pub enum Command {
|
||||
|
||||
/// Run as a Claude Code bridge inside a Docker container (internal use).
|
||||
/// Spawns the `claude` CLI and streams output back to the orchestrator.
|
||||
#[command(hide = true)]
|
||||
ClaudeBridge {
|
||||
/// Job ID to execute.
|
||||
#[arg(long)]
|
||||
@@ -171,6 +225,7 @@ impl Cli {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use clap::CommandFactory;
|
||||
use insta::assert_snapshot;
|
||||
|
||||
#[test]
|
||||
fn test_version() {
|
||||
@@ -180,4 +235,18 @@ mod tests {
|
||||
env!("CARGO_PKG_VERSION")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_help_output() {
|
||||
let mut cmd = Cli::command();
|
||||
let help = cmd.render_help().to_string();
|
||||
assert_snapshot!(help);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_long_help_output() {
|
||||
let mut cmd = Cli::command();
|
||||
let help = cmd.render_long_help().to_string();
|
||||
assert_snapshot!(help);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
source: src/cli/mod.rs
|
||||
expression: help
|
||||
---
|
||||
Secure personal AI assistant that protects your data and expands its capabilities
|
||||
|
||||
Usage: ironclaw [OPTIONS] [COMMAND]
|
||||
|
||||
Commands:
|
||||
run Run the AI agent
|
||||
onboard Run interactive setup wizard
|
||||
config Manage app configs
|
||||
tool Manage WASM tools
|
||||
registry Browse/install extensions
|
||||
mcp Manage MCP servers
|
||||
memory Manage workspace memory
|
||||
pairing Manage DM pairing
|
||||
service Manage OS service
|
||||
doctor Run diagnostics
|
||||
status Show system status
|
||||
completion Generate completions
|
||||
help Print this message or the help of the given subcommand(s)
|
||||
|
||||
Options:
|
||||
--cli-only Run in interactive CLI mode only (disable other channels)
|
||||
--no-db Skip database connection (for testing)
|
||||
-m, --message <MESSAGE> Single message mode - send one message and exit
|
||||
-c, --config <CONFIG> Configuration file path (optional, uses env vars by default)
|
||||
--no-onboard Skip first-run onboarding check
|
||||
-h, --help Print help (see more with '--help')
|
||||
-V, --version Print version
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
source: src/cli/mod.rs
|
||||
expression: help
|
||||
---
|
||||
IronClaw is a secure AI assistant. Use 'ironclaw <subcommand> --help' for details.
|
||||
Examples:
|
||||
ironclaw run # Start the agent
|
||||
ironclaw config list # List configs
|
||||
|
||||
Usage: ironclaw [OPTIONS] [COMMAND]
|
||||
|
||||
Commands:
|
||||
run Run the AI agent
|
||||
onboard Run interactive setup wizard
|
||||
config Manage app configs
|
||||
tool Manage WASM tools
|
||||
registry Browse/install extensions
|
||||
mcp Manage MCP servers
|
||||
memory Manage workspace memory
|
||||
pairing Manage DM pairing
|
||||
service Manage OS service
|
||||
doctor Run diagnostics
|
||||
status Show system status
|
||||
completion Generate completions
|
||||
help Print this message or the help of the given subcommand(s)
|
||||
|
||||
Options:
|
||||
--cli-only
|
||||
Run in interactive CLI mode only (disable other channels)
|
||||
|
||||
--no-db
|
||||
Skip database connection (for testing)
|
||||
|
||||
-m, --message <MESSAGE>
|
||||
Single message mode - send one message and exit
|
||||
|
||||
-c, --config <CONFIG>
|
||||
Configuration file path (optional, uses env vars by default)
|
||||
|
||||
--no-onboard
|
||||
Skip first-run onboarding check
|
||||
|
||||
-h, --help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
-V, --version
|
||||
Print version
|
||||
Reference in New Issue
Block a user