Skip to main content

frs/
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") || cli_args.finish().is_empty() {
18                print!("{}", include_str!("../help.txt"));
19                Ok(())
20            } else {
21                Err(report!("missing repo subcommand"))
22            }
23        }
24        Some("fix") => fix::run(cli_args),
25        Some(command) => Err(report!("unsupported repo command").attach(format!("command={command}"))),
26    }
27}