Commit e2b8ca480b6d
tools/github-notif-manager/src/cache.rs
@@ -25,7 +25,7 @@ impl Cache {
/// Default cache file location
pub fn default_path() -> PathBuf {
let cache_dir = dirs::cache_dir()
- .unwrap_or_else(|| PathBuf::from("~/.cache"))
+ .unwrap_or_else(|| dirs::home_dir().unwrap().join(".cache"))
.join("github-notif-manager");
cache_dir.join("cache.json")
}
tools/github-notif-manager/src/main.rs
@@ -33,7 +33,7 @@ enum Commands {
Process {
/// Path to configuration file
#[arg(short, long)]
- config: PathBuf,
+ config: Option<PathBuf>,
/// Show what would be done without making changes
#[arg(short = 'n', long)]
@@ -47,7 +47,7 @@ enum Commands {
#[arg(short, long)]
all: bool,
- /// Custom cache file path (default: ~/.local/share/github-notif-manager/cache.json)
+ /// Custom cache file path (default: $XDG_CACHE_HOME/github-notif-manager/cache.json)
#[arg(long)]
cache_dir: Option<PathBuf>,
},
@@ -56,7 +56,7 @@ enum Commands {
Validate {
/// Path to configuration file
#[arg(short, long)]
- config: PathBuf,
+ config: Option<PathBuf>,
},
/// List recent notifications (for testing/debugging)
@@ -96,8 +96,8 @@ fn main() -> Result<()> {
verbose,
all,
cache_dir,
- } => cmd_process(config, dry_run, verbose, all, cache_dir),
- Commands::Validate { config } => cmd_validate(config),
+ } => cmd_process(config.unwrap_or_else(default_config_path), dry_run, verbose, all, cache_dir),
+ Commands::Validate { config } => cmd_validate(config.unwrap_or_else(default_config_path)),
Commands::List {
limit,
all,
@@ -107,6 +107,13 @@ fn main() -> Result<()> {
}
}
+fn default_config_path() -> PathBuf {
+ dirs::config_dir()
+ .unwrap_or_else(|| dirs::home_dir().unwrap().join(".config"))
+ .join("github-notif-manager")
+ .join("config.yaml")
+}
+
fn cache_path(cache_dir: Option<PathBuf>) -> PathBuf {
cache_dir.unwrap_or_else(Cache::default_path)
}