extern crate term;
mod commands;
mod paswitch;
mod pulse;
mod types;
use commands::{
check_command,
Type::{Pactl, Paswitch},
};
use paswitch::set_source;
use pulse::{list, search};
use quicli::prelude::CliResult;
use structopt::StructOpt;
use types::Type;
#[derive(Debug, StructOpt)]
struct Cli {
#[structopt(required_unless("list"))]
search: Option<String>,
#[structopt(short, long, default_value = "Description")]
search_key: String,
#[structopt(short, long)]
case_sensitive: bool,
#[structopt(short, long)]
list: bool,
}
fn main() -> CliResult {
let args = Cli::from_args();
check_command(Paswitch)?;
Ok(match Type::from(&args) {
Type::List => list()?,
Type::Set => {
check_command(Pactl)?;
set_source(search(
args.search_key,
args.search.unwrap(),
args.case_sensitive,
)?)?
}
_ => (),
})
}