summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli.rs28
-rw-r--r--src/main.rs17
2 files changed, 23 insertions, 22 deletions
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 @@
1use clap_log_flag;
2use clap_verbosity_flag;
3use structopt; 1use structopt;
2use structopt::clap::arg_enum;
4 3
5#[derive(StructOpt, Debug)] 4#[derive(StructOpt, Debug)]
6#[structopt(raw(setting = "structopt::clap::AppSettings::ColoredHelp"))]
7/// A command-line tool to manipulate PulseAudio's equalizers 5/// A command-line tool to manipulate PulseAudio's equalizers
8pub struct Cli { 6pub struct Cli {
9 #[structopt(flatten)] 7 #[structopt(long, short, parse(from_occurrences))]
10 pub verbose: clap_verbosity_flag::Verbosity, 8 /// Pass many times for more log output
11 #[structopt(flatten)] 9 ///
12 pub log: clap_log_flag::Log, 10 /// By default, it'll only report errors and warnings. Passing `-v` one time
11 /// also prints infos, `-vv` enables debug logging, and `-vvv` trace.
12 pub verbose: u8,
13 #[structopt(subcommand)] 13 #[structopt(subcommand)]
14 pub cmd: Command, 14 pub cmd: Command,
15} 15}
@@ -61,10 +61,8 @@ pub mod pa_eq {
61 #[structopt( 61 #[structopt(
62 short = "f", 62 short = "f",
63 long = "format", 63 long = "format",
64 raw( 64 possible_values = &EqualizerConfFormat::variants(),
65 possible_values = "&EqualizerConfFormat::variants()", 65 case_insensitive = true,
66 case_insensitive = "true"
67 ),
68 default_value = "EqualizerAPO" 66 default_value = "EqualizerAPO"
69 )] 67 )]
70 /// The file format of the equalizer configuration 68 /// The file format of the equalizer configuration
@@ -84,7 +82,6 @@ pub mod pa_eq {
84 /// By default it will use the last equalized sink it finds 82 /// By default it will use the last equalized sink it finds
85 pub sink: Option<String>, 83 pub sink: Option<String>,
86 } 84 }
87
88} 85}
89 86
90#[cfg(feature = "pa-effects")] 87#[cfg(feature = "pa-effects")]
@@ -108,10 +105,8 @@ pub mod pa_effects {
108 #[structopt( 105 #[structopt(
109 short = "f", 106 short = "f",
110 long = "format", 107 long = "format",
111 raw( 108 possible_values = &EqualizerConfFormat::variants(),
112 possible_values = "&EqualizerConfFormat::variants()", 109 case_insensitive = true,
113 case_insensitive = "true"
114 ),
115 default_value = "EqualizerAPO" 110 default_value = "EqualizerAPO"
116 )] 111 )]
117 /// The file format of the equalizer configuration 112 /// The file format of the equalizer configuration
@@ -126,5 +121,4 @@ pub mod pa_effects {
126 /// Write the preset to the given file instead of the standard output 121 /// Write the preset to the given file instead of the standard output
127 pub output: Option<String>, 122 pub output: Option<String>,
128 } 123 }
129
130} 124}
diff --git a/src/main.rs b/src/main.rs
index 23d5a19..062a77c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,10 +4,6 @@ extern crate log;
4extern crate failure; 4extern crate failure;
5 5
6#[macro_use] 6#[macro_use]
7extern crate clap;
8
9
10#[macro_use]
11extern crate structopt; 7extern crate structopt;
12 8
13#[macro_use] 9#[macro_use]
@@ -74,7 +70,18 @@ fn main() {
74 70
75fn start() -> Result<(), Error> { 71fn start() -> Result<(), Error> {
76 let args = Cli::from_args(); 72 let args = Cli::from_args();
77 args.log.log_all(Some(args.verbose.log_level()))?; 73 pretty_env_logger::formatted_builder()
74 .filter(
75 None,
76 match args.verbose {
77 0 => log::LevelFilter::Warn,
78 1 => log::LevelFilter::Info,
79 2 => log::LevelFilter::Debug,
80 _ => log::LevelFilter::Trace,
81 },
82 )
83 .try_init()?;
84
78 85
79 use crate::Command::*; 86 use crate::Command::*;
80 87