aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock102
-rw-r--r--Cargo.toml1
-rw-r--r--README.md12
-rw-r--r--src/db/mod.rs4
-rw-r--r--src/gui/mod.rs3
-rw-r--r--src/main.rs11
6 files changed, 122 insertions, 11 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 9671306..b48421c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -14,6 +14,15 @@ dependencies = [
]
[[package]]
+name = "ansi_term"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
name = "anyhow"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -31,6 +40,17 @@ dependencies = [
]
[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "winapi",
+]
+
+[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -84,6 +104,7 @@ dependencies = [
"rusqlite_migration",
"serde",
"serde_json",
+ "structopt",
"uuid",
]
@@ -126,6 +147,21 @@ dependencies = [
]
[[package]]
+name = "clap"
+version = "2.34.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
+dependencies = [
+ "ansi_term",
+ "atty",
+ "bitflags",
+ "strsim",
+ "textwrap",
+ "unicode-width",
+ "vec_map",
+]
+
+[[package]]
name = "concurrent-queue"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -514,6 +550,15 @@ dependencies = [
]
[[package]]
+name = "hermit-abi"
+version = "0.1.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
+dependencies = [
+ "libc",
+]
+
+[[package]]
name = "itertools"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -529,6 +574,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
name = "libc"
version = "0.2.112"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -800,6 +851,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
[[package]]
+name = "strsim"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
+
+[[package]]
+name = "structopt"
+version = "0.3.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10"
+dependencies = [
+ "clap",
+ "lazy_static",
+ "structopt-derive",
+]
+
+[[package]]
+name = "structopt-derive"
+version = "0.4.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
+dependencies = [
+ "heck",
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
name = "strum"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -860,6 +941,15 @@ dependencies = [
]
[[package]]
+name = "textwrap"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
+dependencies = [
+ "unicode-width",
+]
+
+[[package]]
name = "thiserror"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -912,6 +1002,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
+name = "unicode-width"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
+
+[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -933,6 +1029,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
+name = "vec_map"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
+
+[[package]]
name = "version-compare"
version = "0.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index e79cb87..5d758b7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,4 +13,5 @@ rusqlite = { version = "0.26", features = [ "chrono" ] }
rusqlite_migration = "0.5"
serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"
+structopt = "0.3"
uuid = { version = "0.8", features = [ "v4" ] }
diff --git a/README.md b/README.md
index ce0c140..15206f0 100644
--- a/README.md
+++ b/README.md
@@ -18,16 +18,14 @@ cargo test
## V1
-### Repeat events
+### API
-1. Run `cargo clippy --all-targets -- -D warnings`
-2. Update / delete specific repetition occurences.
-3. When validating repetition, don’t produce None if there is a validation error.
+1. Get list of today’s events.
-### API
+### Repeat events
-1. Give DB path with CLI arg.
-2. Get list of today’s events.
+1. Update / delete specific repetition occurences.
+2. When validating repetition, don’t produce None if there is a validation error.
### Navigate around
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(())
}