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
20/// Available commands.
21#[derive(Subcommand, Debug, Clone)]
22pub enum Command {
23    /// Check file line counts.
24    Check(CheckArgs),
25    /// Create a loq.toml config file.
26    Init(InitArgs),
27    /// Update baseline rules for files exceeding the limit.
28    Baseline(BaselineArgs),
29}
30
31/// Arguments for the check command.
32#[derive(Args, Debug, Clone)]
33pub struct CheckArgs {
34    /// Paths to check (files, directories, or - for stdin).
35    #[arg(value_name = "PATH", allow_hyphen_values = true)]
36    pub paths: Vec<PathBuf>,
37
38    /// Disable file caching.
39    #[arg(long = "no-cache")]
40    pub no_cache: bool,
41}
42
43/// Arguments for the init command.
44#[derive(Args, Debug, Clone)]
45pub struct InitArgs {}
46
47/// Arguments for the baseline command.
48#[derive(Args, Debug, Clone)]
49pub struct BaselineArgs {
50    /// Line threshold for baseline (defaults to `default_max_lines` from config).
51    #[arg(long = "threshold")]
52    pub threshold: Option<usize>,
53
54    /// Allow increasing limits for files that grew beyond their baseline.
55    #[arg(long = "allow-growth")]
56    pub allow_growth: bool,
57}