Page MenuHomePhorge

No OneTemporary

diff --git a/projects/bugphest/src/main.rs b/projects/bugphest/src/main.rs
index 51ef8c4..a7694ea 100644
--- a/projects/bugphest/src/main.rs
+++ b/projects/bugphest/src/main.rs
@@ -1,48 +1,70 @@
mod bugzilla;
mod model;
mod util;
use crate::util::*;
use std::fs::File;
use std::io::BufReader;
use std::io::Read;
use bugzilla::BugzillaClient;
use clap::Parser;
+use clap::Subcommand;
use rusqlite::{Batch, Connection};
#[derive(Parser, Debug)]
-#[command(author, version, about, long_about = None)]
+#[command(version, about, long_about = None)]
struct Args {
- /// Bugzilla password
- #[arg(short, long, env)]
- bugzilla_password: String,
- /// Bugzilla Username
- #[arg(short('u'), long, env)]
- bugzilla_username: String,
+ #[command(subcommand)]
+ /// Fetch or Upload
+ action: Action
}
+#[derive(Subcommand, Debug)]
+enum Action {
+ /// fetches bugs from bugzilla and stores them into sqlite
+ Fetch {
+ /// Bugzilla password
+ #[arg(short, long, env)]
+ bugzilla_password: String,
+
+ /// Bugzilla Username
+ #[arg(short('u'), long, env)]
+ bugzilla_username: String,
+ },
+
+ /// uploads bugs
+ Upload,
+}
+
+
+
+
+
fn main() -> Result<()> {
let args = Args::parse();
let sqlite = Connection::open("migration.db").expect("failed to open sqlite databse");
-let schema_file = File::open("schema.sql").expect("failed to open/read schema.sql file");
+ let schema_file = File::open("schema.sql").expect("failed to open/read schema.sql file");
let mut reader = BufReader::new(schema_file);
let mut schema_sql = String::new();
reader
.read_to_string(&mut schema_sql)
.expect("reading schema.sql file failed");
let mut batch = Batch::new(&sqlite, &schema_sql);
while let Some(mut stmt) = batch.next()? {
stmt.execute([])?;
}
- let bugzilla = BugzillaClient::new(&args.bugzilla_username, &args.bugzilla_password)?;
-
- // TODO: force with a flag or do based on heuristic
- bugzilla.get_all_bugs(&sqlite);
+ match args.action {
+ Action::Fetch{bugzilla_password, bugzilla_username} => {
+ let bugzilla = BugzillaClient::new(&bugzilla_username, &bugzilla_password)?;
+ bugzilla.get_all_bugs(&sqlite);
+ },
+ Action::Upload => unimplemented!(),
+ }
Ok(())
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 20:14 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1128353
Default Alt Text
(2 KB)

Event Timeline