From 557074fb6dadf89ddbfce11d67fe8cac0f9eed80 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sat, 4 Jan 2020 12:23:17 +0100 Subject: Update most dependencies, remove the clap-* ones --- src/cli.rs | 28 +++++++++++----------------- src/main.rs | 17 ++++++++++++----- 2 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/cli.rs b/src/cli.rs index 704c13f..38be6c8 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,15 +1,15 @@ -use clap_log_flag; -use clap_verbosity_flag; use structopt; +use structopt::clap::arg_enum; #[derive(StructOpt, Debug)] -#[structopt(raw(setting = "structopt::clap::AppSettings::ColoredHelp"))] /// A command-line tool to manipulate PulseAudio's equalizers pub struct Cli { - #[structopt(flatten)] - pub verbose: clap_verbosity_flag::Verbosity, - #[structopt(flatten)] - pub log: clap_log_flag::Log, + #[structopt(long, short, parse(from_occurrences))] + /// Pass many times for more log output + /// + /// By default, it'll only report errors and warnings. Passing `-v` one time + /// also prints infos, `-vv` enables debug logging, and `-vvv` trace. + pub verbose: u8, #[structopt(subcommand)] pub cmd: Command, } @@ -61,10 +61,8 @@ pub mod pa_eq { #[structopt( short = "f", long = "format", - raw( - possible_values = "&EqualizerConfFormat::variants()", - case_insensitive = "true" - ), + possible_values = &EqualizerConfFormat::variants(), + case_insensitive = true, default_value = "EqualizerAPO" )] /// The file format of the equalizer configuration @@ -84,7 +82,6 @@ pub mod pa_eq { /// By default it will use the last equalized sink it finds pub sink: Option, } - } #[cfg(feature = "pa-effects")] @@ -108,10 +105,8 @@ pub mod pa_effects { #[structopt( short = "f", long = "format", - raw( - possible_values = "&EqualizerConfFormat::variants()", - case_insensitive = "true" - ), + possible_values = &EqualizerConfFormat::variants(), + case_insensitive = true, default_value = "EqualizerAPO" )] /// The file format of the equalizer configuration @@ -126,5 +121,4 @@ pub mod pa_effects { /// Write the preset to the given file instead of the standard output pub output: Option, } - } diff --git a/src/main.rs b/src/main.rs index 23d5a19..062a77c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,10 +3,6 @@ extern crate log; #[macro_use] extern crate failure; -#[macro_use] -extern crate clap; - - #[macro_use] extern crate structopt; @@ -74,7 +70,18 @@ fn main() { fn start() -> Result<(), Error> { let args = Cli::from_args(); - args.log.log_all(Some(args.verbose.log_level()))?; + pretty_env_logger::formatted_builder() + .filter( + None, + match args.verbose { + 0 => log::LevelFilter::Warn, + 1 => log::LevelFilter::Info, + 2 => log::LevelFilter::Debug, + _ => log::LevelFilter::Trace, + }, + ) + .try_init()?; + use crate::Command::*; -- cgit v1.2.3