diff options
| author | lukeflo | 2025-03-02 22:13:19 +0100 |
|---|---|---|
| committer | lukeflo | 2025-03-02 22:14:13 +0100 |
| commit | 2263f1e14a671c93aa045b5649befbf250712020 (patch) | |
| tree | a653c7723e2c9fc76a5b5290521c211e5a5dfaef /src/cliargs.rs | |
| parent | 2e1204e98704e466c3b210f05478d0275ea3ea71 (diff) | |
| download | bibiman-2263f1e14a671c93aa045b5649befbf250712020.tar.gz bibiman-2263f1e14a671c93aa045b5649befbf250712020.zip | |
implement test if config file exists, otherwise creation of default file will be offered
Diffstat (limited to 'src/cliargs.rs')
| -rw-r--r-- | src/cliargs.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/cliargs.rs b/src/cliargs.rs index 3c302f4..d4fac46 100644 --- a/src/cliargs.rs +++ b/src/cliargs.rs @@ -31,7 +31,7 @@ pub struct CLIArgs { pub helparg: bool, pub versionarg: bool, pub pos_args: Vec<PathBuf>, - pub cfg_path: PathBuf, + pub cfg_path: Option<PathBuf>, pub light_theme: bool, } @@ -42,16 +42,18 @@ impl CLIArgs { // Default config args.cfg_path = if config_dir().is_some() { - config_dir().unwrap().join("bibiman/bibiman.toml") + Some(config_dir().unwrap().join("bibiman/bibiman.toml")) + } else if home_dir().is_some() { + Some(home_dir().unwrap().join(".config/bibiman/bibiman.toml")) } else { - home_dir().unwrap().join(".config/bibiman/bibiman.toml") + None }; while let Some(arg) = parser.next()? { match arg { Short('h') | Long("help") => args.helparg = true, Short('v') | Long("version") => args.versionarg = true, - Short('c') | Long("config-file") => args.cfg_path = parser.value()?.parse()?, + Short('c') | Long("config-file") => args.cfg_path = Some(parser.value()?.parse()?), Long("light-terminal") => args.light_theme = true, // Value(pos_arg) => parse_files(&mut args, pos_arg), Value(pos_arg) => args.pos_args.push(pos_arg.into()), |
