task_graph_mcp/cli/mod.rs
1//! CLI command definitions for task-graph-mcp
2//!
3//! This module defines the CLI structure using clap's derive macros.
4//! The main entry point is the `Cli` struct which contains subcommands.
5
6pub mod agent;
7pub mod diff;
8pub mod export;
9pub mod import;
10pub mod migrate;
11
12use agent::AgentArgs;
13use clap::{Parser, Subcommand, ValueEnum};
14use diff::DiffArgs;
15use export::ExportArgs;
16use import::ImportArgs;
17use migrate::MigrateArgs;
18
19/// UI mode for the server.
20#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, ValueEnum)]
21pub enum UiMode {
22 /// No UI, MCP server only (default)
23 #[default]
24 None,
25 /// Enable web dashboard UI
26 Web,
27}
28
29/// Default port for the web dashboard.
30pub const DEFAULT_UI_PORT: u16 = 31994;
31
32/// Task Graph MCP Server and CLI tools
33#[derive(Parser, Debug)]
34#[command(author, version, about, long_about = None)]
35pub struct Cli {
36 /// Path to configuration file
37 #[arg(short, long, global = true)]
38 pub config: Option<String>,
39
40 /// Path to database file (overrides config)
41 #[arg(short, long, global = true)]
42 pub database: Option<String>,
43
44 /// Path to media directory (overrides config)
45 #[arg(short, long, global = true)]
46 pub media_dir: Option<String>,
47
48 /// Path to log directory (overrides config)
49 #[arg(long, global = true)]
50 pub log_dir: Option<String>,
51
52 /// Enable verbose logging
53 #[arg(short, long, global = true)]
54 pub verbose: bool,
55
56 /// Logging output: 0/off, 1/stdout, 2/stderr (default), or filename
57 #[arg(short, long, default_value = "2", global = true)]
58 pub log: String,
59
60 /// UI mode: none (MCP only) or web (enable dashboard)
61 #[arg(long, value_enum, global = true)]
62 pub ui: Option<UiMode>,
63
64 /// Port for the web dashboard (default: 31994)
65 #[arg(long, global = true)]
66 pub ui_port: Option<u16>,
67
68 /// Start MCP server on stdio (required when no subcommand is given).
69 /// This flag is required to explicitly start the MCP server, preventing
70 /// accidental invocation that would block waiting for MCP input.
71 #[arg(long)]
72 pub stdio: bool,
73
74 #[command(subcommand)]
75 pub command: Option<Command>,
76}
77
78/// Available subcommands
79#[derive(Subcommand, Debug)]
80pub enum Command {
81 /// Start the MCP server (default if no subcommand given)
82 Serve,
83
84 /// Export task database to structured JSON format
85 Export(ExportArgs),
86
87 /// Import task data from a structured JSON export file
88 Import(ImportArgs),
89
90 /// Compare snapshot files or snapshot against database
91 Diff(DiffArgs),
92
93 /// Migrate from deprecated .task-graph/ to task-graph/ directory
94 Migrate(MigrateArgs),
95
96 /// Agent commands for background workers without MCP access
97 Agent(AgentArgs),
98}