git_mover/
cli.rs

1//! Command line options for the git-mover tool
2use crate::{config::Config, platform::PlatformType, utils::main_sync};
3use clap::Parser;
4use serde::Deserialize;
5use std::path::PathBuf;
6
7/// git-mover - Move git repositories to a new location
8#[derive(Parser, Deserialize, Default, Clone, Debug)]
9pub struct GitMoverCli {
10    /// The source platform (github, gitlab, codeberg)
11    #[arg(short, long, visible_alias = "from")]
12    pub source: Option<PlatformType>,
13
14    /// The destination platform (github, gitlab, codeberg)
15    #[arg(short, long, visible_alias = "to")]
16    pub destination: Option<PlatformType>,
17
18    /// Don't sync forked repositories
19    #[arg(short, long = "no-forks")]
20    pub no_forks: bool,
21
22    /// Resync all repositories
23    #[arg(short, long)]
24    pub resync: bool,
25
26    /// Custom configuration file
27    #[arg(short, long)]
28    pub config: Option<String>,
29
30    /// Show the current config path
31    #[arg(long)]
32    pub show_config_path: bool,
33
34    /// Verbose mode (-v, -vv, -vvv)
35    #[arg(short, long, action = clap::ArgAction::Count)]
36    pub verbose: u8,
37}
38
39/// Run the git-mover tool with the provided command line options
40pub async fn cli_main() {
41    let args = GitMoverCli::parse();
42    let config = match &args.config {
43        Some(path_str) => {
44            let path = PathBuf::from(path_str);
45            Config::new_from_path(&path)
46        }
47        None => Config::new(),
48    }
49    .set_debug(args.verbose);
50    if args.show_config_path {
51        println!("{}", config.config_path.display());
52        return;
53    }
54    let mut config = config.with_cli_args(args);
55    main_sync(&mut config).await;
56}