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    /// Disable cache
27    #[arg(short = 'n', long)]
28    pub no_cache: bool,
29
30    /// Overwrite the input file with the translated content
31    #[arg(short = 'w', long)]
32    pub write: bool,
33
34    #[command(subcommand)]
35    pub command: Option<Command>,
36}
37
38/// Available subcommands.
39#[derive(Subcommand, Debug)]
40pub enum Command {
41    /// List supported language codes
42    Languages,
43    /// List configured providers and their models
44    Providers {
45        /// Show models for a specific provider
46        provider: Option<String>,
47    },
48    /// Interactive chat mode for translation
49    Chat {
50        /// Target language code (ISO 639-1, e.g., ja, en, zh)
51        #[arg(short = 't', long = "to")]
52        to: Option<String>,
53
54        /// Provider name (e.g., ollama, openrouter)
55        #[arg(short = 'p', long)]
56        provider: Option<String>,
57
58        /// Model name
59        #[arg(short = 'm', long)]
60        model: Option<String>,
61    },
62}