MCPcopy Create free account
hub / github.com/brocode/fw / _main

Function _main

src/main.rs:12–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10}
11
12fn _main() -> i32 {
13 let matches = crate::app::app().get_matches();
14
15 let config = config::read_config();
16 if config.is_err() {
17 eprintln!(
18 "Could not read v2.0 config: {:?}. If you are running the setup right now this is expected.",
19 config
20 );
21 };
22
23 let subcommand_name = matches.subcommand_name().expect("subcommand required by clap.rs").to_owned();
24 let subcommand_matches = matches.subcommand_matches(&subcommand_name).expect("subcommand matches enforced by clap.rs");
25
26 let result: Result<(), AppError> = match subcommand_name.as_ref() {
27 "sync" => {
28 let worker = subcommand_matches.get_one::<i32>("parallelism").expect("enforced by clap.rs").to_owned();
29
30 sync::synchronize(
31 config,
32 subcommand_matches.get_flag("only-new"),
33 !subcommand_matches.get_flag("no-fast-forward-merge"),
34 &subcommand_matches
35 .get_many::<String>("tag")
36 .unwrap_or_default()
37 .map(ToOwned::to_owned)
38 .collect(),
39 worker,
40 )
41 }
42 "add-remote" => {
43 let name: &str = subcommand_matches.get_one::<String>("NAME").expect("argument required by clap.rs");
44 let remote_name: &str = subcommand_matches.get_one::<String>("REMOTE_NAME").expect("argument required by clap.rs");
45 let url: &str = subcommand_matches.get_one::<String>("URL").expect("argument required by clap.rs");
46 project::add_remote(config, name, remote_name.to_string(), url.to_string())
47 }
48 "remove-remote" => {
49 let name: &str = subcommand_matches.get_one::<String>("NAME").expect("argument required by clap.rs");
50 let remote_name: &str = subcommand_matches.get_one::<String>("REMOTE_NAME").expect("argument required by clap.rs");
51 project::remove_remote(config, name, remote_name.to_string())
52 }
53 "add" => {
54 let name: Option<String> = subcommand_matches.get_one::<String>("NAME").map(ToOwned::to_owned);
55 let url: &str = subcommand_matches.get_one::<String>("URL").expect("argument required by clap.rs");
56 let after_workon: Option<String> = subcommand_matches.get_one::<String>("after-workon").map(ToOwned::to_owned);
57 let after_clone: Option<String> = subcommand_matches.get_one::<String>("after-clone").map(ToOwned::to_owned);
58 let override_path: Option<String> = subcommand_matches.get_one::<String>("override-path").map(ToOwned::to_owned);
59 let tags: Option<BTreeSet<String>> = subcommand_matches
60 .get_many::<String>("tag")
61 .map(|v| v.into_iter().map(ToOwned::to_owned).collect());
62 let trusted = subcommand_matches.get_flag("trusted");
63 project::add_entry(config, name, url, after_workon, after_clone, override_path, tags, trusted)
64 }
65 "remove" => project::remove_project(
66 config,
67 subcommand_matches.get_one::<String>("NAME").expect("argument required by clap.rs"),
68 subcommand_matches.get_flag("purge-directory"),
69 ),

Callers 1

mainFunction · 0.85

Calls 15

appFunction · 0.85
read_configFunction · 0.85
synchronizeFunction · 0.85
add_remoteFunction · 0.85
remove_remoteFunction · 0.85
add_entryFunction · 0.85
remove_projectFunction · 0.85
move_projectFunction · 0.85
update_entryFunction · 0.85
setupFunction · 0.85
importFunction · 0.85
org_importFunction · 0.85

Tested by

no test coverage detected