vika_cli/cli.rs
1use clap::{Parser, Subcommand};
2
3#[derive(Parser)]
4#[command(name = "vika-cli")]
5#[command(version = "0.1.0")]
6#[command(about = "Generate TypeScript clients from Swagger/OpenAPI specs")]
7pub struct Cli {
8 #[command(subcommand)]
9 pub command: Commands,
10}
11
12#[derive(Subcommand)]
13pub enum Commands {
14 /// Initialize a new vika-cli project
15 Init,
16 /// Add a new spec to existing project
17 Add,
18 /// Generate TypeScript code from Swagger spec
19 Generate {
20 /// Path or URL to Swagger/OpenAPI spec (for single-spec mode)
21 #[arg(short, long)]
22 spec: Option<String>,
23 /// Generate all specs (for multi-spec mode)
24 #[arg(long)]
25 all_specs: bool,
26 /// Generate specific spec by name (for multi-spec mode)
27 #[arg(long)]
28 spec_name: Option<String>,
29 /// Enable verbose output
30 #[arg(long)]
31 verbose: bool,
32 /// Use cached spec if available (overrides config)
33 #[arg(long, action = clap::ArgAction::SetTrue)]
34 cache: bool,
35 /// Create backup before writing files (overrides config)
36 #[arg(long, action = clap::ArgAction::SetTrue)]
37 backup: bool,
38 /// Force overwrite user-modified files (overrides config)
39 #[arg(long, action = clap::ArgAction::SetTrue)]
40 force: bool,
41 /// Generate React Query hooks
42 #[arg(long, action = clap::ArgAction::SetTrue)]
43 react_query: bool,
44 /// Generate SWR hooks
45 #[arg(long, action = clap::ArgAction::SetTrue)]
46 swr: bool,
47 },
48 /// Update existing generated code
49 Update,
50 /// Inspect OpenAPI spec without generating code
51 Inspect {
52 /// Path or URL to Swagger/OpenAPI spec (for single-spec mode)
53 #[arg(short, long)]
54 spec: Option<String>,
55 /// Inspect all specs (for multi-spec mode)
56 #[arg(long)]
57 all_specs: bool,
58 /// Inspect specific spec by name (for multi-spec mode)
59 #[arg(long)]
60 spec_name: Option<String>,
61 /// Show details for specific module
62 #[arg(short, long)]
63 module: Option<String>,
64 /// Show schema details
65 #[arg(long)]
66 schemas: bool,
67 /// Show dependency graph
68 #[arg(long)]
69 graph: bool,
70 /// Output as JSON
71 #[arg(long)]
72 json: bool,
73 },
74 /// Manage templates
75 Templates {
76 #[command(subcommand)]
77 command: TemplateCommands,
78 },
79}
80
81#[derive(Subcommand)]
82pub enum TemplateCommands {
83 /// List all available templates
84 List,
85 /// Initialize templates directory with built-in templates
86 Init,
87}