aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db/mod.rs4
-rw-r--r--src/gui/mod.rs3
-rw-r--r--src/main.rs11
3 files changed, 14 insertions, 4 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs
index b27226b..1bbf21e 100644
--- a/src/db/mod.rs
+++ b/src/db/mod.rs
@@ -6,8 +6,8 @@ use uuid::Uuid;
use crate::model::event::Event;
-pub fn init() -> Result<Connection> {
- let mut conn = Connection::open("database.db")?;
+pub fn init(db_path: &str) -> Result<Connection> {
+ let mut conn = Connection::open(db_path)?;
let migrations = Migrations::new(vec![M::up(include_str!("migrations/1-init.sql"))]);
migrations.to_latest(&mut conn)?;
Ok(conn)
diff --git a/src/gui/mod.rs b/src/gui/mod.rs
index a8a025c..c33500b 100644
--- a/src/gui/mod.rs
+++ b/src/gui/mod.rs
@@ -18,7 +18,8 @@ pub fn run(conn: Connection) {
let app = gtk::Application::new(Some("me.guyonvarch.calendar"), Default::default());
app.connect_startup(|_| load_style());
app.connect_activate(move |app| build_ui(conn.clone(), app));
- app.run();
+ let args: [&str; 0] = [];
+ app.run_with_args(&args);
}
fn build_ui(conn: Rc<Connection>, app: &gtk::Application) {
diff --git a/src/main.rs b/src/main.rs
index 8999a52..956e930 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,9 +3,18 @@ mod gui;
mod model;
use anyhow::Result;
+use structopt::StructOpt;
+
+#[derive(StructOpt)]
+#[structopt()]
+struct Opt {
+ #[structopt(long, default_value = "database.db")]
+ database: String,
+}
fn main() -> Result<()> {
- let conn = db::init()?;
+ let db_path = Opt::from_args().database;
+ let conn = db::init(&db_path)?;
gui::run(conn);
Ok(())
}