File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ authors = ["Rik Huijzer"]
66license = " MIT"
77
88[dependencies ]
9+ anyhow = " 1"
910clap = { version = " 4.5.29" , features = [" derive" ] }
11+ futures-util = " 0.3.31"
1012tokio = { version = " 1" , features = [" macros" , " rt-multi-thread" ] }
13+ tracing-subscriber = " 0.3"
14+ tracing = " 0.1"
1115transformrs = " 0.6"
12- anyhow = " 1"
13- futures-util = " 0.3.31"
1416
1517[dev-dependencies ]
1618assert_cmd = " 2"
Original file line number Diff line number Diff line change 44use chat:: ChatArgs ;
55use clap:: Parser ;
66use std:: io:: Read ;
7+ use tracing:: subscriber:: SetGlobalDefaultError ;
78use transformrs:: Key ;
89use tts:: TextToSpeechArgs ;
910
@@ -30,6 +31,12 @@ enum Commands {
3031struct Arguments {
3132 #[ command( subcommand) ]
3233 command : Commands ,
34+ /// Verbose output.
35+ ///
36+ /// The output of the logs is printed to stderr because the output is
37+ /// printed to stdout.
38+ #[ arg( long) ]
39+ verbose : bool ,
3340}
3441
3542pub enum Task {
@@ -46,9 +53,25 @@ fn find_single_key(keys: transformrs::Keys) -> Key {
4653 keys[ 0 ] . clone ( )
4754}
4855
56+ /// Initialize logging with the given level.
57+ fn init_subscriber ( level : tracing:: Level ) -> Result < ( ) , SetGlobalDefaultError > {
58+ let subscriber = tracing_subscriber:: FmtSubscriber :: builder ( )
59+ . with_max_level ( level)
60+ . with_writer ( std:: io:: stderr)
61+ . without_time ( )
62+ . with_target ( false )
63+ . finish ( ) ;
64+ tracing:: subscriber:: set_global_default ( subscriber)
65+ }
66+
4967#[ tokio:: main]
5068async fn main ( ) {
5169 let args = Arguments :: parse ( ) ;
70+ if args. verbose {
71+ init_subscriber ( tracing:: Level :: DEBUG ) . unwrap ( ) ;
72+ } else {
73+ init_subscriber ( tracing:: Level :: INFO ) . unwrap ( ) ;
74+ }
5275
5376 let mut input = String :: new ( ) ;
5477 std:: io:: stdin ( ) . read_to_string ( & mut input) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments