1use clap::{Arg, ArgAction, Command};
7
8#[derive(Debug)]
10pub struct Config {
11 pub path: String,
13 pub dry_run: bool,
15 pub verbose: bool,
17 pub restore: bool,
19 pub show_guide: bool,
21 pub oracle_only: bool,
23}
24
25impl Config {
26 pub fn new() -> Self {
31 let matches = Command::new("soon-migrate")
32 .version("0.2.0")
33 .author("Akshat Sharma <akshatsharma0023@outlook.com>")
34 .about("Migrates Solana Anchor projects to SOON Network with oracle detection")
35 .arg(
36 Arg::new("path")
37 .help("Path to the Anchor project")
38 .default_value(".")
39 .index(1),
40 )
41 .arg(
42 Arg::new("dry-run")
43 .long("dry-run")
44 .help("Show changes without applying them")
45 .action(ArgAction::SetTrue),
46 )
47 .arg(
48 Arg::new("verbose")
49 .long("verbose")
50 .short('v')
51 .help("Enable detailed logging")
52 .action(ArgAction::SetTrue),
53 )
54 .arg(
55 Arg::new("restore")
56 .long("restore")
57 .help("Restore from backup")
58 .action(ArgAction::SetTrue),
59 )
60 .arg(
61 Arg::new("show-guide")
62 .long("show-guide")
63 .help("Show detailed APRO integration guide")
64 .action(ArgAction::SetTrue),
65 )
66 .arg(
67 Arg::new("oracle-only")
68 .long("oracle-only")
69 .help("Only scan for oracles, don't perform migration")
70 .action(ArgAction::SetTrue),
71 )
72 .get_matches();
73
74 Config {
75 path: matches.get_one::<String>("path").unwrap().to_string(),
76 dry_run: matches.get_flag("dry-run"),
77 verbose: matches.get_flag("verbose"),
78 restore: matches.get_flag("restore"),
79 show_guide: matches.get_flag("show-guide"),
80 oracle_only: matches.get_flag("oracle-only"),
81 }
82 }
83}