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    /// Sync manually
35    #[arg(short, long)]
36    pub manual: bool,
37
38    /// Verbose mode (-v, -vv, -vvv)
39    #[arg(short, long, action = clap::ArgAction::Count)]
40    pub verbose: u8,
41}
42
43/// Run the git-mover tool with the provided command line options
44pub async fn cli_main() {
45    let args = GitMoverCli::parse();
46    let config_path = args.config.clone();
47    let mut config = match config_path {
48        Some(path_str) => {
49            let path = PathBuf::from(path_str);
50            Config::new_from_path(args, &path)
51        }
52        None => Config::new(args),
53    };
54    if config.cli_args.show_config_path {
55        println!("{}", config.config_path.display());
56        return;
57    }
58    main_sync(&mut config).await;
59}