aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2021-07-14 14:24:51 +0100
committerdiogo464 <[email protected]>2021-07-14 14:24:51 +0100
commit74a90b975d7a448950625bc767b8052fe8bef0d4 (patch)
treeda9c0f22af5427df73c949cc65c84416a404179f
parent68fea411d5f7fe6c4d38ddc11b897c48b45122e4 (diff)
Removed .rustfmt file
-rw-r--r--dotup_cli/src/.main.rs.rustfmt87
1 files changed, 0 insertions, 87 deletions
diff --git a/dotup_cli/src/.main.rs.rustfmt b/dotup_cli/src/.main.rs.rustfmt
deleted file mode 100644
index 6d020e1..0000000
--- a/dotup_cli/src/.main.rs.rustfmt
+++ /dev/null
@@ -1,87 +0,0 @@
1#![allow(unused)]
2
3pub mod commands;
4pub mod config;
5
6pub use config::Config;
7
8pub mod prelude {
9 pub use super::Config;
10 pub use dotup::{Archive, Depot, DepotConfig, Link, LinkDesc, LinkID};
11}
12
13use clap::{AppSettings, Clap};
14use flexi_logger::Logger;
15use std::{
16 collections::HashMap,
17 iter::FromIterator,
18 path::{Path, PathBuf},
19};
20
21use prelude::*;
22
23const DEFAULT_DEPOT_NAME: &str = "depot.toml";
24
25#[derive(Clap)]
26#[clap(version = "0.1", author = "d464")]
27#[clap(setting = AppSettings::ColoredHelp)]
28struct Opts {
29 /// Path to the depot file.
30 #[clap(long, default_value = DEFAULT_DEPOT_NAME)]
31 depot: PathBuf,
32
33 /// Disable output to the console
34 #[clap(short, long)]
35 quiet: bool,
36
37 /// A level of verbosity, and can be used multiple times
38 ///
39 /// Level 0 - Warnings (Default)
40 /// Level 1 - Info
41 /// Level 2 - Debug
42 /// Level 3 - Trace
43 #[clap(short, long, parse(from_occurrences))]
44 verbose: i32,
45
46 #[clap(subcommand)]
47 subcmd: SubCommand,
48}
49
50#[derive(Clap)]
51enum SubCommand {
52 Init(commands::init::Opts),
53 Link(commands::link::Opts),
54 Unlink(commands::unlink::Opts),
55 Install(commands::install::Opts),
56 Uninstall(commands::uninstall::Opts),
57}
58
59fn main() -> anyhow::Result<()> {
60 let opts = Opts::parse();
61
62 if !opts.quiet {
63 let log_level = match opts.verbose {
64 0 => "warn",
65 1 => "info",
66 2 => "debug",
67 3 | _ => "trace",
68 };
69
70 Logger::try_with_env_or_str(log_level)?
71 .format(flexi_logger::colored_default_format)
72 //.set_palette("196;208;32;198;15".to_string())
73 .start()?;
74 }
75
76 let config = Config {
77 archive_path: opts.depot,
78 };
79
80 match opts.subcmd {
81 SubCommand::Init(opts) => commands::init::main(config, opts),
82 SubCommand::Link(opts) => commands::link::main(config, opts),
83 SubCommand::Unlink(opts) => commands::unlink::main(config, opts),
84 SubCommand::Install(opts) => commands::install::main(config, opts),
85 SubCommand::Uninstall(opts) => commands::uninstall::main(config, opts),
86 }
87}