mirror of
https://git.alemi.dev/memo-cli.git
synced 2024-11-22 00:04:48 +01:00
improved compatibility (kind of)
windows support is still a loooong way to go - replaced env!("HOME") with dirs::home_dir() - replaced libnotify with notify_rust - set to use bundled libcipher (encryption not implemented yet)
This commit is contained in:
parent
35960af854
commit
212d41221e
3 changed files with 18 additions and 14 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -8,3 +8,6 @@ Cargo.lock
|
|||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
#CLion stuff
|
||||
**/.idea/
|
|
@ -17,10 +17,11 @@ colored = "2.0.0"
|
|||
rpassword = "6.0.1"
|
||||
git-version = "0.3.5" # ughh just for git hash
|
||||
const_format = "0.2.22" # ughh just for git hash
|
||||
libnotify = "1.0.3"
|
||||
notify-rust = "4"
|
||||
uuid = { version = "0.8.2", features = ["v4"] }
|
||||
clap = { version = "3.1.6", features = ["derive"] }
|
||||
rusqlite = { version="0.27.0", features=["chrono", "backup"] }
|
||||
rusqlite = { version="0.27.0", features=["bundled-sqlcipher", "chrono", "backup"] }
|
||||
dirs = "4.0.0" # cross-platform paths
|
||||
ureq = { version="2.4.0", features=["json"] }
|
||||
|
||||
[profile.release]
|
||||
|
|
24
src/main.rs
24
src/main.rs
|
@ -11,6 +11,7 @@ use regex::Regex;
|
|||
use storage::{open_sqlite_storage, Memo, MemoStorage, AuthStorage, StateStorage, SQLiteStorage};
|
||||
use utils::{find_by_regex, parse_human_duration, HumanDisplay};
|
||||
use remote::RemoteSync;
|
||||
use notify_rust::Notification;
|
||||
|
||||
const GIT_VERSION: &str = git_version!();
|
||||
const PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
@ -65,14 +66,16 @@ enum Commands {
|
|||
|
||||
fn main() {
|
||||
let args = Cli::parse();
|
||||
let home_path = std::env!("HOME").to_string();
|
||||
let mut db_path: String = home_path + "/.local/share/memo-cli.db";
|
||||
//let home_path = std::env!("HOME").to_string(); //this is linux-only
|
||||
let mut db_path: std::path::PathBuf = dirs::home_dir().unwrap();
|
||||
db_path.push(".local/share/memo-cli.db"); //+ "/.local/share/memo-cli.db";
|
||||
//WARNING: this is only for testing, it has no proper error handling and will panic is HOME is invalid or None
|
||||
|
||||
if let Some(db) = args.path {
|
||||
db_path = db;
|
||||
db_path = std::path::PathBuf::from(db);
|
||||
}
|
||||
|
||||
let storage = open_sqlite_storage(&db_path, true).unwrap();
|
||||
let storage = open_sqlite_storage(db_path.to_str().unwrap(), true).unwrap();
|
||||
|
||||
if args.sync {
|
||||
if storage.get_key().is_err() {
|
||||
|
@ -170,14 +173,11 @@ fn main() {
|
|||
builder.push('\n');
|
||||
}
|
||||
if args.notify {
|
||||
libnotify::init("memo-cli").unwrap();
|
||||
let n = libnotify::Notification::new(
|
||||
format!("memo-cli | {}", timing).as_str(),
|
||||
Some(builder.as_str()),
|
||||
None,
|
||||
);
|
||||
n.show().unwrap();
|
||||
libnotify::uninit();
|
||||
Notification::new()
|
||||
.summary(format!("memo-cli | {}", timing).as_str())
|
||||
.body(builder.as_str())
|
||||
//.icon("") //soon...
|
||||
.show();
|
||||
} else {
|
||||
println!("{} | {}", "memo-cli".bold(), timing);
|
||||
print!("{}", builder);
|
||||
|
|
Loading…
Reference in a new issue