summaryrefslogtreecommitdiff
path: root/makima/src/daemon/cli/mod.rs
blob: 077a37e92fa69de6420570f1e30f2d9bcaeb41bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! Command-line interface for the makima CLI.

pub mod config;
pub mod daemon;
pub mod directive;
pub mod server;

use clap::{Parser, Subcommand};

pub use config::CliConfig;
pub use daemon::DaemonArgs;
pub use directive::DirectiveArgs;
pub use server::ServerArgs;

/// Makima - unified CLI for server, daemon, and task management.
#[derive(Parser, Debug)]
#[command(name = "makima")]
#[command(version, about = "Makima CLI - server, daemon, and task management", long_about = None)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand, Debug)]
pub enum Commands {
    /// Run the makima server
    Server(ServerArgs),

    /// Run the daemon (connect to server, manage tasks)
    Daemon(DaemonArgs),

    /// Directive commands for DAG-based project management
    #[command(subcommand)]
    Directive(DirectiveCommand),

    /// Configure CLI settings (API key, server URL)
    ///
    /// Saves configuration to ~/.makima/config.toml for use by CLI commands.
    #[command(subcommand)]
    Config(ConfigCommand),
}

/// Config subcommands for CLI configuration.
#[derive(Subcommand, Debug)]
pub enum ConfigCommand {
    /// Set the API key
    ///
    /// Saves the API key to ~/.makima/config.toml
    SetKey(config::SetKeyArgs),

    /// Set the API URL
    ///
    /// Saves the API URL to ~/.makima/config.toml
    SetUrl(config::SetUrlArgs),

    /// Show current configuration
    Show,

    /// Show the config file path
    Path,
}

// SupervisorCommand and ContractCommand removed in Phase 5 — contracts
// subsystem is gone. See cli/contract.rs and cli/supervisor.rs deletion.

/// Directive subcommands for DAG-based project management.
#[derive(Subcommand, Debug)]
pub enum DirectiveCommand {
    /// List all directives
    List(directive::DirectiveListArgs),

    /// Get directive status with steps
    Get(DirectiveArgs),

    /// Get directive status (alias for get)
    Status(DirectiveArgs),

    /// Add a step to the directive
    AddStep(directive::AddStepArgs),

    /// Remove a step from the directive
    RemoveStep(directive::RemoveStepArgs),

    /// Set dependencies for a step
    SetDeps(directive::SetDepsArgs),

    /// Start the directive (begin executing steps)
    Start(DirectiveArgs),

    /// Pause the directive
    Pause(DirectiveArgs),

    /// Advance the DAG (find newly-ready steps)
    Advance(DirectiveArgs),

    /// Mark a step as completed
    CompleteStep(directive::StepActionArgs),

    /// Mark a step as failed
    FailStep(directive::StepActionArgs),

    /// Mark a step as skipped
    SkipStep(directive::StepActionArgs),

    /// Batch add multiple steps from JSON
    BatchAddSteps(directive::BatchAddStepsArgs),

    /// Update directive metadata (PR URL, etc.)
    Update(directive::UpdateArgs),

    /// Ask a question and wait for user feedback
    Ask(directive::AskArgs),

    /// Create an order for future work (spike or chore only)
    CreateOrder(directive::CreateOrderArgs),

    /// Verify the current worktree merges cleanly into the directive's base branch.
    ///
    /// Mandatory pre-flight before creating or pushing a directive PR — fails
    /// with a non-zero exit code (and a list of conflicting files) if the merge
    /// would conflict with the base branch.
    Verify(directive::VerifyArgs),
}

impl Cli {
    /// Parse command-line arguments
    pub fn parse_args() -> Self {
        Self::parse()
    }
}