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    /// Don't delete repositories
23    #[arg(long = "no-delete")]
24    pub no_delete: bool,
25
26    /// Resync all repositories
27    #[arg(short, long)]
28    pub resync: bool,
29
30    /// Custom configuration file path
31    #[arg(short, long)]
32    pub config: Option<String>,
33
34    /// Show the current config path
35    #[arg(long)]
36    pub show_config_path: bool,
37
38    /// Sync manually
39    #[arg(short, long)]
40    pub manual: bool,
41
42    /// Verbose mode (-v, -vv, -vvv)
43    #[arg(short, long, action = clap::ArgAction::Count)]
44    pub verbose: u8,
45}
46
47/// Run the git-mover tool with the provided command line options
48pub async fn cli_main() {
49    let args = GitMoverCli::parse();
50    let config_path = args.config.clone();
51    let mut config = match config_path {
52        Some(path_str) => {
53            let path = PathBuf::from(path_str);
54            Config::new_from_path(args, &path)
55        }
56        None => Config::new(args),
57    };
58    if config.cli_args.show_config_path {
59        println!("{}", config.config_path.display());
60        return;
61    }
62    main_sync(&mut config).await;
63}