Skip to main content

apple_code_assistant/cli/
parser.rs

1//! CLI argument parser (clap)
2
3use clap::Parser;
4
5#[derive(Parser, Debug)]
6#[command(name = "apple-code")]
7#[command(version, about = "Apple Code Assistant - Generate code using Apple Foundation Models")]
8pub struct Args {
9    /// Code generation prompt
10    #[arg(short, long)]
11    pub prompt: Option<String>,
12
13    /// Programming language (typescript, python, etc.)
14    #[arg(short, long)]
15    pub language: Option<String>,
16
17    /// Output file path
18    #[arg(short, long)]
19    pub output: Option<String>,
20
21    /// Interactive mode (default when no prompt provided)
22    #[arg(short, long)]
23    pub interactive: bool,
24
25    /// Configuration file path
26    #[arg(short, long)]
27    pub config: Option<String>,
28
29    /// Apple Foundation Model to use
30    #[arg(short, long)]
31    pub model: Option<String>,
32
33    /// Prompt template name (from config)
34    #[arg(short = 'T', long)]
35    pub template: Option<String>,
36
37    /// Temperature for code generation (0-2)
38    #[arg(short, long, default_value = "0.7")]
39    pub temperature: f32,
40
41    /// Maximum tokens to generate
42    #[arg(long, default_value = "4000")]
43    pub max_tokens: u32,
44
45    /// Maximum number of characters to use for piped stdin and context
46    #[arg(long)]
47    pub char_limit: Option<usize>,
48
49    /// Save generated code to file
50    #[arg(short, long)]
51    pub save: bool,
52
53    /// Copy generated code to clipboard
54    #[arg(long)]
55    pub copy: bool,
56
57    /// Preview generated code in terminal
58    #[arg(long)]
59    pub preview: bool,
60
61    /// Edit existing file with generated code
62    #[arg(short, long)]
63    pub edit: Option<String>,
64
65    /// Additional context for code generation
66    #[arg(long)]
67    pub context: Option<String>,
68
69    /// Glob patterns for additional context files
70    #[arg(long = "context-glob")]
71    pub context_glob: Vec<String>,
72
73    /// Terminal theme (light/dark)
74    #[arg(long, default_value = "dark")]
75    pub theme: String,
76
77    /// Disable colored output
78    #[arg(long)]
79    pub no_color: bool,
80
81    /// Verbose output
82    #[arg(long)]
83    pub verbose: bool,
84
85    /// Debug mode
86    #[arg(long)]
87    pub debug: bool,
88
89    /// Extend previous conversation instead of starting a new one
90    #[arg(short = 'e', long)]
91    pub extend_conversation: bool,
92
93    /// Repeat input before output (useful for editor integration)
94    #[arg(short = 'r', long)]
95    pub repeat_input: bool,
96
97    /// Raw/tool mode: print plain output without preview formatting
98    #[arg(long)]
99    pub tool_mode: bool,
100
101    #[command(subcommand)]
102    pub subcommand: Option<Subcommand>,
103}
104
105#[derive(clap::Subcommand, Debug)]
106pub enum Subcommand {
107    /// Manage configuration
108    Config {
109        /// Set configuration value (key=value)
110        #[arg(long)]
111        set: Option<String>,
112        /// Get configuration value
113        #[arg(long)]
114        get: Option<String>,
115        /// List all configuration values
116        #[arg(long)]
117        list: bool,
118        /// Reset configuration to defaults
119        #[arg(long)]
120        reset: bool,
121    },
122    /// List available Apple Foundation Models
123    Models,
124    /// List supported programming languages
125    Languages,
126    /// Test API connection
127    Test,
128}