aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJoris Guyonvarch2025-05-02 11:22:40 +0200
committerJoris Guyonvarch2025-05-02 11:22:40 +0200
commit7e56ec0f49ff30c750f5c44b65fb13442352ca89 (patch)
tree81c2c03ba4bab9e22210d4fee426f1352a742acb /src/main.rs
parent99f483927b1b8dd96be5846f338d37a37ab667ec (diff)
Replace --list-today by --date today
Allow also using: - --date yesterday - --date tomorrow - --date YYYY-MM-DD
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs
index 8eafd77..e61a771 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -14,11 +14,11 @@ struct Opt {
#[clap(long = "database", default_value = "database.sqlite3")]
db_path: String,
- /// List today’s events as plain text
- #[clap(long = "list-today")]
- list_today: bool,
+ /// Started at events as plain text
+ #[clap(long = "date")]
+ date: Option<String>,
- /// Start between <timestamp..timestamp> events as plain text
+ /// Started between <timestamp..timestamp> events as plain text
#[clap(long = "start-between")]
start_between: Option<String>,
}
@@ -26,17 +26,17 @@ struct Opt {
fn main() -> Result<()> {
let Opt {
db_path,
- list_today,
+ date,
start_between,
} = Opt::parse();
let conn = db::init(&db_path)?;
- if list_today {
- print!("{}", cli::today(&conn)?);
- } else {
- match start_between.and_then(cli::parse_timestamp_range) {
+
+ match date.and_then(cli::parse_date) {
+ Some(date) => print!("{}", cli::started_at_date(&conn, date)?),
+ None => match start_between.and_then(cli::parse_timestamp_range) {
Some((from, to)) => print!("{}", cli::start_between(&conn, from, to)?),
None => gui::run(conn),
- }
+ },
};
Ok(())
}