1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#![warn(
clippy::all,
clippy::pedantic,
clippy::nursery,
clippy::cargo,
missing_debug_implementations
)]
#![allow(
clippy::module_name_repetitions,
clippy::implicit_return,
clippy::missing_inline_in_public_items,
clippy::missing_docs_in_private_items,
clippy::missing_errors_doc
)]
use anyhow::Result;
use args::GenerateLib;
use log::trace;
use tasks::update_self;
use crate::{
args::{Args, SubCommand},
config::UpConfig,
tasks::git,
};
pub mod args;
mod config;
mod env;
mod generate;
pub mod tasks;
pub mod update;
pub fn run(args: Args) -> Result<()> {
match args.cmd {
Some(SubCommand::Link(link_options)) => {
tasks::link::run(link_options)?;
}
Some(SubCommand::Git(git_options)) => {
git::update::update(&git_options.into())?;
}
Some(SubCommand::Defaults {}) => {
unimplemented!("Not yet implemented.");
}
Some(SubCommand::Self_(opts)) => {
update_self::run(&opts)?;
}
Some(SubCommand::Generate(ref opts)) => match opts.lib {
Some(GenerateLib::Git(ref git_opts)) => {
generate::git::run_single(git_opts)?;
}
Some(GenerateLib::Defaults(ref defaults_opts)) => {
trace!("Options: {:?}", defaults_opts);
unimplemented!("Allow generating defaults toml.");
}
None => {
let config = UpConfig::from(args)?;
generate::run(&config)?;
}
},
Some(SubCommand::Run(ref _opts)) => {
let config = UpConfig::from(args)?;
update::update(&config)?;
}
None => {
let config = UpConfig::from(args)?;
update::update(&config)?;
}
}
Ok(())
}