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
90
91
92
#![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 update::update_self::update_self;
use crate::{
args::{Args, SubCommand},
config::UpConfig,
tasks::{git, link::LinkConfig},
};
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 {
from_dir,
to_dir,
backup_dir,
}) => {
tasks::link::run(LinkConfig {
from_dir: shellexpand::tilde(&from_dir).into_owned(),
to_dir: shellexpand::tilde(&to_dir).into_owned(),
backup_dir: shellexpand::tilde(&backup_dir).into_owned(),
})?;
}
Some(SubCommand::Git(git_args)) => {
git::update::update(&git_args.into())?;
}
Some(SubCommand::Defaults {}) => {
unimplemented!("Not yet implemented.");
}
Some(SubCommand::Self_(opts)) => {
update_self(&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 tasks = args.tasks.clone();
let config = UpConfig::from(args)?;
generate::run(&config, &tasks)?;
}
},
None => {
let tasks = args.tasks.clone();
let config = UpConfig::from(args)?;
update::update(&config, &tasks)?;
}
}
Ok(())
}