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    /// Suppress summary output.
16    #[arg(short = 'q', long = "quiet", global = true)]
17    pub quiet: bool,
18
19    /// Suppress all output.
20    #[arg(long = "silent", global = true)]
21    pub silent: bool,
22
23    /// Show extra information.
24    #[arg(short = 'v', long = "verbose", global = true)]
25    pub verbose: bool,
26
27    /// Path to loq.toml config file.
28    #[arg(long = "config", value_name = "PATH", global = true)]
29    pub config: Option<PathBuf>,
30}
31
32/// Available commands.
33#[derive(Subcommand, Debug, Clone)]
34pub enum Command {
35    /// Validate files against configured constraints.
36    Check(CheckArgs),
37    /// Create a loq.toml config file.
38    Init(InitArgs),
39}
40
41/// Arguments for the check command.
42#[derive(Args, Debug, Clone)]
43pub struct CheckArgs {
44    /// Paths to check (files, directories, or - for stdin).
45    #[arg(value_name = "PATH", allow_hyphen_values = true)]
46    pub paths: Vec<PathBuf>,
47}
48
49/// Arguments for the init command.
50#[derive(Args, Debug, Clone)]
51pub struct InitArgs {
52    /// Generate config that exempts current violations.
53    #[arg(long = "baseline")]
54    pub baseline: bool,
55}