aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2022-03-13 13:07:09 +0100
committerTeddy Wing2022-03-13 13:07:09 +0100
commit8c02343737f4f980dc4e28f3892ed75d07527816 (patch)
treed31f9519289127cb823a86752f40308fe4935da9
parent7e12b718aedc2990be51f1168e79b4b67261a477 (diff)
downloadyaqlite-8c02343737f4f980dc4e28f3892ed75d07527816.tar.bz2
main(): Add subcommands and arguments
Trying to match the subcommand enum, but apparently can't get a variant (`Command::Insert`) out of the `@` binding, it seems it ends up being a `Command` type.
-rw-r--r--src/main.rs32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index b770fa9..d12015a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,19 +4,31 @@ use yaml_rust::yaml;
#[derive(clap::Parser, Debug)]
-#[clap()]
+#[clap(version)]
struct Args {
#[clap(subcommand)]
command: Command,
-
- #[clap(long)]
- database: String,
}
#[derive(clap::Subcommand, Debug)]
enum Command {
- Insert,
- Select,
+ Insert {
+ #[clap(long)]
+ database: String,
+
+ table_name: String,
+
+ input_file: Option<String>,
+ },
+
+ Select {
+ #[clap(long)]
+ database: String,
+
+ table_name: String,
+
+ record_id: String,
+ },
}
@@ -27,6 +39,14 @@ fn main() {
// Get column names from SQLite
+ match args.command {
+ a @ Command::Insert { .. } => {
+ dbg!(a.database);
+ }
+
+ a @ Command::Select { .. } => {}
+ };
+
let mut dbconn = rusqlite::Connection::open("./test.db").unwrap();
let text_data = std::fs::read_to_string("test2.yml").unwrap();