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:
Francesco Tolomei 2022-03-23 20:01:24 +01:00
parent 35960af854
commit 212d41221e
No known key found for this signature in database
GPG key ID: 739BF0B2B1CEDE39
3 changed files with 18 additions and 14 deletions

3
.gitignore vendored
View file

@ -8,3 +8,6 @@ Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
#CLion stuff
**/.idea/

View file

@ -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]

View file

@ -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);