-// mod configuration;
+mod configuration;
mod lyrics_engine;
mod sources;
use std::io::{Result, Error, ErrorKind::Other};
-use clap::{Parser};
+use clap::Parser;
+use configuration::Configuration;
use sources::{enable, disable, get_track, reset, list};
use lyrics_engine::print_lyrics;
#[tokio::main]
async fn main() -> Result<()> {
+ let mut configuration = Configuration::new();
let arguments = Arguments::parse();
if arguments.list_sources {
- return list();
+ let sources = list();
+ for source in sources {
+ print!("{}", source);
+ if configuration.is_enabled(&source) {
+ print!(" (enabled)");
+ }
+ println!("");
+ }
+ return Ok(());
}
if let Some(source_name) = arguments.enable_source {
- return enable(source_name);
+ if !configuration.is_enabled(&source_name) {
+ enable(&source_name)?;
+ }
+ return configuration.enable_source(&source_name);
}
if let Some(source_name) = arguments.disable_source {
- return disable(source_name);
+ if configuration.is_enabled(&source_name) {
+ disable(&source_name)?;
+ }
+ return configuration.disable_source(&source_name);
}
if let Some(source_name) = arguments.reset_source {
- return reset(source_name);
+ return reset(&source_name);
}
let current_track: Track;