mammoth_cli/
cli.rs

1use clap::{Parser, Subcommand};
2
3#[derive(Parser)]
4#[command(name = "mammoth-cli")]
5#[command(about = "Mammoth - A powerful frontend project scaffolding CLI tool")]
6#[command(version)]
7pub struct Cli {
8    /// Enable verbose output
9    #[arg(short, long)]
10    pub verbose: bool,
11    
12    #[command(subcommand)]
13    pub command: Option<Commands>,
14}
15
16#[derive(Subcommand)]
17pub enum Commands {
18    /// Create a new project
19    New {
20        /// Template ID
21        #[arg(short, long)]
22        template: Option<String>,
23        
24        /// Project name
25        #[arg(short, long)]
26        name: Option<String>,
27        
28        /// Output directory
29        #[arg(short, long, default_value = ".")]
30        output: String,
31    },
32    /// Clean configuration and cache
33    Clean {
34        /// Also remove configuration file
35        #[arg(short, long)]
36        all: bool,
37        
38        /// Skip confirmation
39        #[arg(short, long)]
40        force: bool,
41    },
42    /// Show configuration information
43    Info {
44        /// Show as JSON format
45        #[arg(short, long)]
46        json: bool,
47    },
48    /// Template management
49    Template {
50        #[command(subcommand)]
51        command: TemplateCommands,
52    },
53    /// Repository management
54    Repo {
55        #[command(subcommand)]
56        command: RepoCommands,
57    },
58    /// Configuration management
59    Config {
60        #[command(subcommand)]
61        command: ConfigCommands,
62    },
63}
64
65#[derive(Subcommand)]
66pub enum TemplateCommands {
67    /// List all available templates
68    List {
69        /// Show detailed information
70        #[arg(short, long)]
71        verbose: bool,
72    },
73    /// Download/update a specific template
74    Download {
75        /// Template ID
76        template_id: String,
77        
78        /// Force update
79        #[arg(short, long)]
80        force: bool,
81    },
82    /// Download/update all templates
83    DownloadAll {
84        /// Force update
85        #[arg(short, long)]
86        force: bool,
87    },
88    /// Add a new template
89    Add {
90        /// Template ID
91        template_id: String,
92        
93        /// Template name
94        #[arg(short, long)]
95        name: String,
96        
97        /// Repository name
98        #[arg(short, long)]
99        repo: String,
100        
101        /// Template path in repository
102        #[arg(short, long)]
103        path: String,
104        
105        /// Template description
106        #[arg(short, long)]
107        description: String,
108        
109        /// Language
110        #[arg(short, long, default_value = "vue")]
111        language: String,
112        
113        /// Tags (comma-separated)
114        #[arg(short, long)]
115        tags: Option<String>,
116    },
117    /// Remove a template
118    Remove {
119        /// Template ID
120        template_id: String,
121    },
122}
123
124#[derive(Subcommand)]
125pub enum RepoCommands {
126    /// Add a new repository
127    Add {
128        /// Repository name
129        repo_name: String,
130        
131        /// Repository URL
132        #[arg(short, long)]
133        url: String,
134        
135        /// Branch
136        #[arg(short, long, default_value = "main")]
137        branch: String,
138    },
139    /// Remove a repository
140    Remove {
141        /// Repository name
142        repo_name: String,
143    },
144    /// List all repositories
145    List,
146}
147
148#[derive(Subcommand)]
149pub enum ConfigCommands {
150    /// Export configuration to file
151    Export {
152        /// Output file path
153        #[arg(short, long)]
154        output: String,
155        
156        /// Include cache information
157        #[arg(short, long)]
158        include_cache: bool,
159    },
160    /// Import configuration from file
161    Import {
162        /// Input file path
163        #[arg(short, long)]
164        file: String,
165        
166        /// Import mode: merge (default) or overwrite
167        #[arg(short, long, default_value = "merge")]
168        mode: String,
169        
170        /// Skip validation
171        #[arg(short, long)]
172        skip_validation: bool,
173    },
174    /// Validate configuration file
175    Validate {
176        /// Configuration file path
177        file: String,
178    },
179}