1use std::path::PathBuf;
4
5use clap::{Args, Parser, Subcommand, ValueEnum};
6
7#[derive(Parser, Debug)]
9#[command(name = "loq", version, about = "Enforce file size constraints")]
10pub struct Cli {
11 #[command(subcommand)]
13 pub command: Option<Command>,
14
15 #[arg(short = 'v', long = "verbose", global = true)]
17 pub verbose: bool,
18}
19
20#[derive(Subcommand, Debug, Clone)]
22pub enum Command {
23 Check(CheckArgs),
25 Init(InitArgs),
27 Baseline(BaselineArgs),
29 Tighten(TightenArgs),
31 Relax(RelaxArgs),
33}
34
35#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, ValueEnum)]
37pub enum OutputFormat {
38 #[default]
40 Text,
41 Json,
43}
44
45#[derive(Args, Debug, Clone)]
47pub struct CheckArgs {
48 #[arg(value_name = "PATH", conflicts_with_all = ["staged", "diff"])]
50 pub paths: Vec<PathBuf>,
51
52 #[arg(long = "stdin", hide = true, conflicts_with_all = ["staged", "diff"])]
54 pub stdin: bool,
55
56 #[arg(long = "staged", conflicts_with = "diff")]
58 pub staged: bool,
59
60 #[arg(long = "diff", value_name = "REF", conflicts_with = "staged")]
62 pub diff: Option<String>,
63
64 #[arg(long = "no-cache")]
66 pub no_cache: bool,
67
68 #[arg(long = "output-format", value_enum, default_value_t = OutputFormat::Text)]
70 pub output_format: OutputFormat,
71}
72
73#[derive(Args, Debug, Clone)]
75pub struct InitArgs {}
76
77#[derive(Args, Debug, Clone)]
79pub struct BaselineArgs {
80 #[arg(long = "threshold")]
82 pub threshold: Option<usize>,
83}
84
85#[derive(Args, Debug, Clone)]
87pub struct TightenArgs {
88 #[arg(long = "threshold")]
90 pub threshold: Option<usize>,
91}
92
93#[derive(Args, Debug, Clone)]
95pub struct RelaxArgs {
96 #[arg(value_name = "FILE")]
98 pub files: Vec<PathBuf>,
99
100 #[arg(long = "extra", visible_alias = "buffer", default_value_t = 0)]
102 pub extra: usize,
103}