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    /// Append every reducer `Msg` to a JSONL file at this path for
38    /// debugging / post-mortem replay. Interactive mode only.
39    #[arg(long, value_name = "FILE")]
40    pub record: Option<PathBuf>,
41
42    #[command(subcommand)]
43    pub command: Option<Commands>,
44}
45
46#[derive(Subcommand, Debug)]
47pub enum Commands {
48    /// Initialize configuration
49    Init,
50    /// List available models
51    List,
52    /// Start a chat session (default)
53    Chat,
54    /// Show version information
55    Version,
56    /// Check status of dependencies and backends
57    Status,
58    /// Add an MCP server (e.g., mermaid add context7)
59    Add {
60        /// MCP server name (e.g., context7, github, filesystem)
61        name: String,
62    },
63    /// Remove a configured MCP server
64    Remove {
65        /// MCP server name to remove
66        name: String,
67    },
68    /// List configured MCP servers
69    Mcp,
70    /// Configure Ollama Cloud API key (interactive prompt). Run this
71    /// from your shell before starting mermaid — it reads stdin and
72    /// doesn't work from inside the TUI.
73    CloudSetup,
74    /// Run a single prompt non-interactively
75    Run {
76        /// The prompt to execute
77        prompt: String,
78
79        /// Output format (text, json, markdown)
80        #[arg(short, long, value_enum, default_value_t = OutputFormat::Text)]
81        format: OutputFormat,
82
83        /// Maximum tokens to generate
84        #[arg(long)]
85        max_tokens: Option<usize>,
86
87        /// Don't execute agent actions (dry run)
88        #[arg(long)]
89        no_execute: bool,
90    },
91}
92
93#[derive(Debug, Clone, Copy, ValueEnum)]
94pub enum OutputFormat {
95    /// Plain text output
96    Text,
97    /// JSON structured output
98    Json,
99    /// Markdown formatted output
100    Markdown,
101}