5 use std::io::{Result, Error, ErrorKind::Other};
8 use sources::{enable, disable, get_track, reset, list};
9 use lyrics_engine::print_lyrics;
11 #[derive(Parser, Debug)]
12 #[command(version, about, long_about = None)]
15 // Positional Arguments
16 /// Specify the artist.
17 artist: Option<String>,
19 /// Specify the artist.
20 track_name: Option<String>,
22 /// Show title of track if present
23 #[arg(short = 't', long)]
31 #[arg(short, long, value_name = "SOURCE")]
32 enable_source: Option<String>,
34 #[arg(short, long, value_name = "SOURCE")]
35 disable_source: Option<String>,
37 #[arg(short, long, value_name = "SOURCE")]
38 reset_source: Option<String>,
47 async fn main() -> Result<()> {
48 let arguments = Arguments::parse();
50 if arguments.list_sources {
54 if let Some(source_name) = arguments.enable_source {
55 return enable(source_name);
58 if let Some(source_name) = arguments.disable_source {
59 return disable(source_name);
62 if let Some(source_name) = arguments.reset_source {
63 return reset(source_name);
66 let current_track: Track;
67 if let Some(artist) = arguments.artist {
68 current_track = Track {
69 name: arguments.track_name.unwrap_or("".to_string()),
73 current_track = get_track()
74 .ok_or_else(|| Error::new(Other, "No Artist/Song could be found :("))?
77 print_lyrics(current_track, arguments.show_title).await