Skip to main content

mermaid_cli/cli/
args.rs

1use clap::{Parser, Subcommand, ValueEnum};
2use std::path::PathBuf;
3
4use crate::models::ReasoningLevel;
5
6#[derive(Parser, Debug)]
7#[command(name = "mermaid")]
8#[command(version)]
9#[command(about = "An open-source, model-agnostic AI pair programmer", long_about = None)]
10pub struct Cli {
11    /// Model to use (e.g., qwen3-coder:30b, ollama/llama3)
12    #[arg(short, long)]
13    pub model: Option<String>,
14
15    /// Reasoning depth (none, minimal, low, medium, high, max).
16    /// Overrides the persisted default for this session; the slash
17    /// command `/reasoning <level>` and Alt+T can change it at runtime.
18    #[arg(long)]
19    pub reasoning: Option<ReasoningLevel>,
20
21    /// Project directory (defaults to current directory)
22    #[arg(short, long)]
23    pub path: Option<PathBuf>,
24
25    /// Verbose output
26    #[arg(short, long)]
27    pub verbose: bool,
28
29    /// Show session picker to choose a previous conversation
30    #[arg(long, conflicts_with = "continue_session")]
31    pub sessions: bool,
32
33    /// Resume the last conversation instead of starting fresh
34    #[arg(long = "continue", conflicts_with = "sessions")]
35    pub continue_session: bool,
36
37    #[command(subcommand)]
38    pub command: Option<Commands>,
39}
40
41#[derive(Subcommand, Debug)]
42pub enum Commands {
43    /// Initialize configuration
44    Init,
45    /// List available models
46    List,
47    /// Start a chat session (default)
48    Chat,
49    /// Show version information
50    Version,
51    /// Check status of dependencies and backends
52    Status,
53    /// Add an MCP server (e.g., mermaid add context7)
54    Add {
55        /// MCP server name (e.g., context7, github, filesystem)
56        name: String,
57    },
58    /// Remove a configured MCP server
59    Remove {
60        /// MCP server name to remove
61        name: String,
62    },
63    /// List configured MCP servers
64    Mcp,
65    /// Run a single prompt non-interactively
66    Run {
67        /// The prompt to execute
68        prompt: String,
69
70        /// Output format (text, json, markdown)
71        #[arg(short, long, value_enum, default_value_t = OutputFormat::Text)]
72        format: OutputFormat,
73
74        /// Maximum tokens to generate
75        #[arg(long)]
76        max_tokens: Option<usize>,
77
78        /// Don't execute agent actions (dry run)
79        #[arg(long)]
80        no_execute: bool,
81    },
82}
83
84#[derive(Debug, Clone, Copy, ValueEnum)]
85pub enum OutputFormat {
86    /// Plain text output
87    Text,
88    /// JSON structured output
89    Json,
90    /// Markdown formatted output
91    Markdown,
92}