Skip to main content

minion_engine/cli/
mod.rs

1mod commands;
2pub mod display;
3pub mod init_templates;
4
5use clap::{Parser, Subcommand};
6
7#[derive(Parser)]
8#[command(
9    name = "minion",
10    about = "AI Workflow Engine — orchestrate Claude Code CLI with YAML workflows",
11    version,
12    after_help = "\x1b[1mQuick start:\x1b[0m
13  cargo install --path .
14  export ANTHROPIC_API_KEY=\"sk-ant-...\"
15  gh auth login
16  minion execute workflows/code-review.yaml --sandbox -- <PR_NUMBER>
17
18\x1b[1mRequirements:\x1b[0m
19  • ANTHROPIC_API_KEY   — required for AI steps (chat, map)
20  • gh auth login       — required for GitHub-based workflows (GH_TOKEN auto-detected)
21  • Docker Desktop      — required for --sandbox mode (creates isolated containers)
22
23\x1b[1mExamples:\x1b[0m
24  minion execute workflows/code-review.yaml -- 42        Review PR #42 (sandbox on by default)
25  minion execute workflows/fix-issue.yaml -- 123         Fix issue #123
26  minion execute my-workflow.yaml --no-sandbox -- main   Run without Docker sandbox
27  minion list                                            List available workflows
28  minion init my-workflow --template code-review         Create a new workflow"
29)]
30pub struct Cli {
31    #[command(subcommand)]
32    command: Command,
33}
34
35#[derive(Subcommand)]
36enum Command {
37    /// Run a workflow
38    Execute(commands::ExecuteArgs),
39    /// Validate a workflow YAML without running
40    Validate(commands::ValidateArgs),
41    /// List available workflows (current dir, ./workflows/, ~/.minion/workflows/)
42    List,
43    /// Create a new workflow from a template
44    Init(commands::InitArgs),
45    /// Inspect a workflow: show config, scopes, dependency graph and dry-run summary
46    Inspect(commands::InspectArgs),
47    /// Show version
48    Version,
49}
50
51impl Cli {
52    pub async fn run(self) -> anyhow::Result<()> {
53        match self.command {
54            Command::Execute(args) => commands::execute(args).await,
55            Command::Validate(args) => commands::validate(args).await,
56            Command::List => commands::list().await,
57            Command::Init(args) => commands::init(args).await,
58            Command::Inspect(args) => commands::inspect(args).await,
59            Command::Version => {
60                println!("minion {}", env!("CARGO_PKG_VERSION"));
61                Ok(())
62            }
63        }
64    }
65}