Skip to main content

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 diff;
7pub mod export;
8pub mod import;
9pub mod migrate;
10
11use clap::{Parser, Subcommand, ValueEnum};
12use diff::DiffArgs;
13use export::ExportArgs;
14use import::ImportArgs;
15use migrate::MigrateArgs;
16
17/// UI mode for the server.
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, ValueEnum)]
19pub enum UiMode {
20    /// No UI, MCP server only (default)
21    #[default]
22    None,
23    /// Enable web dashboard UI
24    Web,
25}
26
27/// Default port for the web dashboard.
28pub const DEFAULT_UI_PORT: u16 = 31994;
29
30/// Task Graph MCP Server and CLI tools
31#[derive(Parser, Debug)]
32#[command(author, version, about, long_about = None)]
33pub struct Cli {
34    /// Path to configuration file
35    #[arg(short, long, global = true)]
36    pub config: Option<String>,
37
38    /// Path to database file (overrides config)
39    #[arg(short, long, global = true)]
40    pub database: Option<String>,
41
42    /// Path to media directory (overrides config)
43    #[arg(short, long, global = true)]
44    pub media_dir: Option<String>,
45
46    /// Path to log directory (overrides config)
47    #[arg(long, global = true)]
48    pub log_dir: Option<String>,
49
50    /// Enable verbose logging
51    #[arg(short, long, global = true)]
52    pub verbose: bool,
53
54    /// Logging output: 0/off, 1/stdout, 2/stderr (default), or filename
55    #[arg(short, long, default_value = "2", global = true)]
56    pub log: String,
57
58    /// UI mode: none (MCP only) or web (enable dashboard)
59    #[arg(long, value_enum, global = true)]
60    pub ui: Option<UiMode>,
61
62    /// Port for the web dashboard (default: 31994)
63    #[arg(long, global = true)]
64    pub ui_port: Option<u16>,
65
66    #[command(subcommand)]
67    pub command: Option<Command>,
68}
69
70/// Available subcommands
71#[derive(Subcommand, Debug)]
72pub enum Command {
73    /// Start the MCP server (default if no subcommand given)
74    Serve,
75
76    /// Export task database to structured JSON format
77    Export(ExportArgs),
78
79    /// Import task data from a structured JSON export file
80    Import(ImportArgs),
81
82    /// Compare snapshot files or snapshot against database
83    Diff(DiffArgs),
84
85    /// Migrate from deprecated .task-graph/ to task-graph/ directory
86    Migrate(MigrateArgs),
87}