tl_cli/cli/args.rs
1//! CLI argument definitions using clap.
2
3use clap::{Parser, Subcommand};
4
5/// Command-line arguments for the `tl` CLI.
6#[derive(Parser, Debug)]
7#[command(name = "tl")]
8#[command(about = "AI-powered translation CLI tool")]
9#[command(version)]
10pub struct Args {
11 /// File to translate (reads from stdin if not provided)
12 pub file: Option<String>,
13
14 /// Target language code (ISO 639-1, e.g., ja, en, zh)
15 #[arg(short = 't', long = "to")]
16 pub to: Option<String>,
17
18 /// Provider name (e.g., ollama, openrouter)
19 #[arg(short = 'p', long)]
20 pub provider: Option<String>,
21
22 /// Model name
23 #[arg(short = 'm', long)]
24 pub model: Option<String>,
25
26 /// Translation style (e.g., casual, formal, literal, natural)
27 #[arg(short = 's', long)]
28 pub style: Option<String>,
29
30 /// Disable cache
31 #[arg(short = 'n', long)]
32 pub no_cache: bool,
33
34 /// Overwrite the input file with the translated content
35 #[arg(short = 'w', long)]
36 pub write: bool,
37
38 #[command(subcommand)]
39 pub command: Option<Command>,
40}
41
42/// Available subcommands.
43#[derive(Subcommand, Debug)]
44pub enum Command {
45 /// List supported language codes
46 Languages,
47 /// Manage providers (list all if no subcommand given)
48 Providers {
49 #[command(subcommand)]
50 command: Option<ProvidersCommand>,
51 },
52 /// Manage translation styles (list all if no subcommand given)
53 Styles {
54 #[command(subcommand)]
55 command: Option<StylesCommand>,
56 },
57 /// Interactive chat mode for translation
58 Chat {
59 /// Target language code (ISO 639-1, e.g., ja, en, zh)
60 #[arg(short = 't', long = "to")]
61 to: Option<String>,
62
63 /// Provider name (e.g., ollama, openrouter)
64 #[arg(short = 'p', long)]
65 provider: Option<String>,
66
67 /// Model name
68 #[arg(short = 'm', long)]
69 model: Option<String>,
70
71 /// Translation style (e.g., casual, formal, literal, natural)
72 #[arg(short = 's', long)]
73 style: Option<String>,
74 },
75 /// Configure default settings
76 Configure,
77}
78
79/// Subcommands for provider management.
80#[derive(Subcommand, Debug)]
81pub enum ProvidersCommand {
82 /// Add a new provider
83 Add,
84 /// Edit an existing provider
85 Edit {
86 /// Provider name to edit
87 name: String,
88 },
89 /// Remove a provider
90 Remove {
91 /// Provider name to remove
92 name: String,
93 },
94}
95
96/// Subcommands for style management.
97#[derive(Subcommand, Debug)]
98pub enum StylesCommand {
99 /// Add a new custom style
100 Add,
101 /// Show details of a style (description and prompt)
102 Show {
103 /// Style name to show
104 name: String,
105 },
106 /// Edit an existing custom style
107 Edit {
108 /// Style name to edit
109 name: String,
110 },
111 /// Remove a custom style
112 Remove {
113 /// Style name to remove
114 name: String,
115 },
116}