From 581aca2fb1957badc4d640e64deab070706a45a7 Mon Sep 17 00:00:00 2001 From: alemidev Date: Tue, 15 Mar 2022 22:17:24 +0100 Subject: [PATCH] include git hash into version --- Cargo.toml | 2 ++ src/main.rs | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a999ab2..a81b3e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,8 @@ edition = "2021" [dependencies] regex = "1" chrono = "0.4.19" +git-version = "0.3.5" # ughh just for git hash +const_format = "0.2.22" # ughh just for git hash libnotify = "1.0.3" clap = { version = "3.1.6", features = ["derive"] } rusqlite = { version="0.27.0", features=["chrono"] } diff --git a/src/main.rs b/src/main.rs index 70e67f9..b2f8b70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,11 +4,18 @@ mod utils; use chrono::{DateTime, Utc, Local}; use clap::{Parser, Subcommand}; use regex::Regex; -pub use storage::{open_sqlite_storage, Memo, MemoStorage}; +use storage::{open_sqlite_storage, Memo, MemoStorage}; use utils::{parse_human_duration, HumanDisplay}; +use git_version::git_version; +use const_format::concatcp; + +const GIT_VERSION: &str = git_version!(); +const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); +const VERSION: &str = concatcp!(PKG_VERSION, "-", GIT_VERSION); #[derive(Parser)] -#[clap(author, version, about, long_about = None)] +#[clap(author, about, long_about = None)] +#[clap(version = VERSION)] #[clap(disable_colored_help = true)] #[clap(subcommand_required = false)] #[clap(disable_help_subcommand = true)] @@ -20,11 +27,12 @@ struct Cli { #[clap(long, help = "show completed tasks")] old: bool, #[clap(short, long, help = "location for database file")] - db_path: Option, + path: Option, } #[derive(Subcommand)] enum Commands { + /// create a new memo #[clap(trailing_var_arg = true)] New { #[clap(multiple_values = true)] @@ -34,6 +42,7 @@ enum Commands { #[clap(short, long, help = "due time relative to now")] due: Option, // TODO allow to pass date }, + /// mark existing memo as done Done { search: String, #[clap(long, help = "delete more than one task if matched")] @@ -46,7 +55,7 @@ fn main() { let home_path = std::env!("HOME").to_string(); let mut db_path: String = home_path + "/.local/share/memo-cli.db"; - if let Some(db) = args.db_path { + if let Some(db) = args.path { db_path = db; }