summaryrefslogtreecommitdiff
path: root/makima/src/daemon/cli/chain.rs
blob: 1d7c16726c45b9ea27a89455b7152b7d11a0ae5b (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
//! Chain CLI commands for multi-contract orchestration.
//!
//! Provides commands for creating, managing, and visualizing chains
//! (DAGs of contracts).

use clap::Args;
use std::path::PathBuf;
use uuid::Uuid;

/// Common arguments for chain commands requiring API access.
#[derive(Args, Debug, Clone)]
pub struct ChainArgs {
    /// API URL
    #[arg(long, env = "MAKIMA_API_URL", default_value = "https://api.makima.jp", global = true)]
    pub api_url: String,

    /// API key for authentication
    #[arg(long, env = "MAKIMA_API_KEY", global = true)]
    pub api_key: String,
}

/// Arguments for the `run` command (create chain from YAML file).
#[derive(Args, Debug)]
pub struct RunArgs {
    #[command(flatten)]
    pub common: ChainArgs,

    /// Path to the chain YAML file
    pub file: PathBuf,

    /// Don't actually create the chain, just validate and show what would be created
    #[arg(long)]
    pub dry_run: bool,
}

/// Arguments for the `status` command.
#[derive(Args, Debug)]
pub struct StatusArgs {
    #[command(flatten)]
    pub common: ChainArgs,

    /// Chain ID
    pub chain_id: Uuid,
}

/// Arguments for the `list` command.
#[derive(Args, Debug)]
pub struct ListArgs {
    #[command(flatten)]
    pub common: ChainArgs,

    /// Filter by status (active, completed, archived)
    #[arg(long)]
    pub status: Option<String>,

    /// Limit number of results
    #[arg(long, default_value = "50")]
    pub limit: i32,
}

/// Arguments for the `contracts` command.
#[derive(Args, Debug)]
pub struct ContractsArgs {
    #[command(flatten)]
    pub common: ChainArgs,

    /// Chain ID
    pub chain_id: Uuid,
}

/// Arguments for the `graph` command (ASCII DAG visualization).
#[derive(Args, Debug)]
pub struct GraphArgs {
    #[command(flatten)]
    pub common: ChainArgs,

    /// Chain ID
    pub chain_id: Uuid,

    /// Show contract status in nodes
    #[arg(long)]
    pub with_status: bool,
}

/// Arguments for the `validate` command.
#[derive(Args, Debug)]
pub struct ValidateArgs {
    /// Path to the chain YAML file
    pub file: PathBuf,
}

/// Arguments for the `preview` command.
#[derive(Args, Debug)]
pub struct PreviewArgs {
    /// Path to the chain YAML file
    pub file: PathBuf,
}

/// Arguments for the `archive` command.
#[derive(Args, Debug)]
pub struct ArchiveArgs {
    #[command(flatten)]
    pub common: ChainArgs,

    /// Chain ID
    pub chain_id: Uuid,
}