From 92b05a877eb772985d2f4fc9cd198ca642b69b6a Mon Sep 17 00:00:00 2001 From: diogo464 Date: Tue, 8 Feb 2022 09:21:12 +0000 Subject: removed old code --- dotup_cli/src/main.rs | 111 -------------------------------------------------- 1 file changed, 111 deletions(-) delete mode 100644 dotup_cli/src/main.rs (limited to 'dotup_cli/src/main.rs') diff --git a/dotup_cli/src/main.rs b/dotup_cli/src/main.rs deleted file mode 100644 index 0d730da..0000000 --- a/dotup_cli/src/main.rs +++ /dev/null @@ -1,111 +0,0 @@ -#![allow(unused)] - -pub mod commands; -pub mod config; -pub mod utils; - -pub use config::Config; - -pub mod prelude { - pub use super::{utils, Config}; - pub use clap::{AppSettings, Parser}; - pub use dotup::{Archive, Depot, DepotConfig, Link, LinkCreateParams, LinkID}; -} - -use clap::{AppSettings, Parser}; -use flexi_logger::Logger; -use std::{ - collections::HashMap, - iter::FromIterator, - path::{Path, PathBuf}, -}; - -use prelude::*; - -#[derive(Parser)] -struct Opts { - /// Path to the depot file. - /// - /// By default it will try to find a file named "depot.toml" in the current directory or any of - /// the parent directories. - #[clap(long)] - depot: Option, - - /// Disable output to the console - #[clap(short, long)] - quiet: bool, - - /// A level of verbosity, and can be used multiple times - /// - /// Level 1 - Info - /// - /// Level 2 - Debug - /// - /// Level 3 - Trace - #[clap(short, long, parse(from_occurrences))] - verbose: i32, - - /// The location where links will be installed to. - /// Defaults to the home directory. - #[clap(short, long)] - install_path: Option, - - #[clap(subcommand)] - subcmd: SubCommand, -} - -#[derive(Parser)] -enum SubCommand { - Init(commands::init::Opts), - Link(commands::link::Opts), - Mv(commands::mv::Opts), - Status(commands::status::Opts), - Unlink(commands::unlink::Opts), - Install(commands::install::Opts), - Uninstall(commands::uninstall::Opts), -} - -fn main() -> anyhow::Result<()> { - let opts = Opts::parse(); - - if !opts.quiet { - let log_level = match opts.verbose { - 0 => "warn", - 1 => "info", - 2 => "debug", - _ => "trace", - }; - - Logger::try_with_env_or_str(log_level)? - .format(flexi_logger::colored_default_format) - .set_palette("196;208;32;198;15".to_string()) - .start()?; - } - - let archive_path = match opts.depot { - Some(path) => path, - None => utils::find_archive_path()?, - }; - let install_path = match opts.install_path { - Some(path) => path, - None => utils::home_directory()?, - }; - let working_path = std::env::current_dir().expect("Failed to obtain current working directory"); - log::debug!("Archive path : {}", archive_path.display()); - - let config = Config { - archive_path, - install_path, - working_path, - }; - - match opts.subcmd { - SubCommand::Init(opts) => commands::init::main(config, opts), - SubCommand::Link(opts) => commands::link::main(config, opts), - SubCommand::Mv(opts) => commands::mv::main(config, opts), - SubCommand::Status(opts) => commands::status::main(config, opts), - SubCommand::Unlink(opts) => commands::unlink::main(config, opts), - SubCommand::Install(opts) => commands::install::main(config, opts), - SubCommand::Uninstall(opts) => commands::uninstall::main(config, opts), - } -} -- cgit