Skip to main content

frs/cmds/
repo.rs

1//! Implementation of the `frs repo` command.
2
3use rootcause::report;
4use ytil_sys::pico_args::Arguments;
5
6mod fix;
7
8/// Runs the `frs repo` command.
9///
10/// # Errors
11/// - The subcommand is unknown or its arguments are invalid.
12/// - Repo maintenance fails.
13pub fn run(mut cli_args: Arguments) -> rootcause::Result<()> {
14    let command = cli_args.subcommand()?;
15    match command.as_deref() {
16        None => {
17            if cli_args.contains("--help") {
18                print!("{}", crate::cmds::Help::Repo.text());
19                return Ok(());
20            }
21            if cli_args.finish().is_empty() {
22                eprintln!("{}", crate::cmds::Help::Repo.text());
23                return Err(report!("missing frs repo command"));
24            }
25            Err(report!("missing repo subcommand"))
26        }
27        Some("fix") => fix::run(cli_args),
28        Some(command) => Err(report!("unsupported repo command").attach(format!("command={command}"))),
29    }
30}