loq_cli/
cli.rs

1//! CLI argument definitions.
2
3use std::path::PathBuf;
4
5use clap::{Args, Parser, Subcommand};
6
7/// Parsed command-line arguments.
8#[derive(Parser, Debug)]
9#[command(name = "loq", version, about = "Enforce file size constraints")]
10pub struct Cli {
11    /// Subcommand to run.
12    #[command(subcommand)]
13    pub command: Option<Command>,
14
15    /// Show extra information.
16    #[arg(short = 'v', long = "verbose", global = true)]
17    pub verbose: bool,
18
19    /// Path to loq.toml config file.
20    #[arg(long = "config", value_name = "PATH", global = true)]
21    pub config: Option<PathBuf>,
22}
23
24/// Available commands.
25#[derive(Subcommand, Debug, Clone)]
26pub enum Command {
27    /// Check file line counts.
28    Check(CheckArgs),
29    /// Create a loq.toml config file.
30    Init(InitArgs),
31    /// Update baseline rules for files exceeding the limit.
32    Baseline(BaselineArgs),
33}
34
35/// Arguments for the check command.
36#[derive(Args, Debug, Clone)]
37pub struct CheckArgs {
38    /// Paths to check (files, directories, or - for stdin).
39    #[arg(value_name = "PATH", allow_hyphen_values = true)]
40    pub paths: Vec<PathBuf>,
41
42    /// Disable file caching.
43    #[arg(long = "no-cache")]
44    pub no_cache: bool,
45}
46
47/// Arguments for the init command.
48#[derive(Args, Debug, Clone)]
49pub struct InitArgs {}
50
51/// Arguments for the baseline command.
52#[derive(Args, Debug, Clone)]
53pub struct BaselineArgs {
54    /// Line threshold for baseline (defaults to `default_max_lines` from config).
55    #[arg(long = "threshold")]
56    pub threshold: Option<usize>,
57}