consume crate direcories
* provides target agnostic directory locations * find config file in a target system standard location Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -22,6 +22,7 @@ chrono = { version = "~0.4.0", features = ["serde"] }
|
||||
cfg-if = { version = "~1.0" }
|
||||
clap = { version = "~2.33", features = ["suggestions", "color"] }
|
||||
csv = { version = "~1.1" }
|
||||
directories = { version = "~3.0" }
|
||||
dotenv = { version = "~0.15.0" }
|
||||
envy = { version = "~0.4" }
|
||||
lettre ={ version = "0.10.0-rc.3" }
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
* Copyright 2020-2021 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
*/
|
||||
|
||||
// parse CLI commandline arguments with clap
|
||||
use clap::{crate_authors, crate_description, crate_name, crate_version, App, Arg};
|
||||
|
||||
//use log::{debug, info, trace, warn};
|
||||
use directories::{BaseDirs, UserDirs, ProjectDirs};
|
||||
use std::env;
|
||||
use tracing::trace;
|
||||
use viperus::Viperus;
|
||||
@@ -26,6 +24,38 @@ pub fn parse_args(viperus: &mut Viperus) -> Result<(), Box<dyn std::error::Error
|
||||
println!("Using feature fmt-clap");
|
||||
}
|
||||
|
||||
if let Some(proj_dirs) = ProjectDirs::from("de", "Networkx GmbH", "advotracker") {
|
||||
proj_dirs.config_dir();
|
||||
// Lin: $HOME/.config/advotracker
|
||||
// Win: C:\Users\%USERNAME%\AppData\Roaming\Networkx GmbH\advotracker\config
|
||||
// Mac: /Users/$USER/Library/Application Support/de.Networkx-GmbH.advotracker
|
||||
trace!(target: "ProjectDirs", "Viperus feature 'fmt-clap' enabled.");
|
||||
}
|
||||
|
||||
if let Some(proj_dirs) = ProjectDirs::from("de", "Networkx GmbH", "advotracker") {
|
||||
proj_dirs.config_dir();
|
||||
// Lin: $HOME/.config/advotracker
|
||||
// Win: C:\Users\%USERNAME%\AppData\Roaming\Networkx GmbH\advotracker\config
|
||||
// Mac: /Users/$USER/Library/Application Support/de.Networkx-GmbH.advotracker
|
||||
trace!(target: "directories", config_dir = ?proj_dirs.config_dir().display());
|
||||
}
|
||||
|
||||
// if let Some(base_dirs) = BaseDirs::new() {
|
||||
// base_dirs.executable_dir();
|
||||
// // Lin: Some($HOME/.local/bin)
|
||||
// // Win: None
|
||||
// // Mac: None
|
||||
// trace!(target: "directories", executable_dir = ?base_dirs.executable_dir().unwrap());
|
||||
// }
|
||||
|
||||
if let Some(user_dirs) = UserDirs::new() {
|
||||
user_dirs.picture_dir();
|
||||
// Lin: /home/alice/Pictures
|
||||
// Win: C:\Users\Alice\Pictures
|
||||
// Mac: /Users/Alice/Pictures
|
||||
trace!(target: "directories", audio_dir = ?user_dirs.picture_dir().unwrap());
|
||||
}
|
||||
|
||||
// preset default key/value pairs (lowest priority)
|
||||
viperus.add_default("config_file", String::from("csv_import.ron"));
|
||||
viperus.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
||||
|
||||
Reference in New Issue
Block a user