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    },
42    /// Update existing generated code
43    Update,
44    /// Inspect OpenAPI spec without generating code
45    Inspect {
46        /// Path or URL to Swagger/OpenAPI spec (for single-spec mode)
47        #[arg(short, long)]
48        spec: Option<String>,
49        /// Inspect all specs (for multi-spec mode)
50        #[arg(long)]
51        all_specs: bool,
52        /// Inspect specific spec by name (for multi-spec mode)
53        #[arg(long)]
54        spec_name: Option<String>,
55        /// Show details for specific module
56        #[arg(short, long)]
57        module: Option<String>,
58        /// Show schema details
59        #[arg(long)]
60        schemas: bool,
61        /// Show dependency graph
62        #[arg(long)]
63        graph: bool,
64        /// Output as JSON
65        #[arg(long)]
66        json: bool,
67    },
68    /// Manage templates
69    Templates {
70        #[command(subcommand)]
71        command: TemplateCommands,
72    },
73}
74
75#[derive(Subcommand)]
76pub enum TemplateCommands {
77    /// List all available templates
78    List,
79    /// Initialize templates directory with built-in templates
80    Init,
81}