summaryrefslogtreecommitdiffstats
path: root/src/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 1976d93..c2cae24 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -3,7 +3,11 @@ const _DUMMY_DEPENDENCY: &'static str = include_str!("../Cargo.toml");
pub enum Command {
Sync {
username: String,
- }
+ },
+ SQL {
+ query: String,
+ tsv: bool,
+ },
}
pub fn get_options() -> failure::Fallible<Command> {
@@ -17,6 +21,20 @@ pub fn get_options() -> failure::Fallible<Command> {
.help("last.fm username to fetch tracks for")
)
)
+ .subcommand(
+ clap::SubCommand::with_name("sql")
+ .about("Run a query against the local database")
+ .arg(
+ clap::Arg::with_name("query")
+ .required(true)
+ .help("query to run")
+ )
+ .arg(
+ clap::Arg::with_name("tsv")
+ .long("tsv")
+ .help("format output as tsv")
+ )
+ )
.get_matches();
let command = match matches.subcommand() {
@@ -25,6 +43,12 @@ pub fn get_options() -> failure::Fallible<Command> {
username: matches.value_of("username").unwrap().to_string(),
}
},
+ ("sql", Some(matches)) => {
+ Command::SQL {
+ query: matches.value_of("query").unwrap().to_string(),
+ tsv: matches.is_present("tsv"),
+ }
+ },
(name, Some(_)) => bail!("unknown subcommand: {}", name),
(_, None) => bail!("no subcommand given"),
};