Skip to content

Commit 5c3fd59

Browse files
committed
fix paths
1 parent 9f6af78 commit 5c3fd59

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl Default for ConfigCliOptions {
321321
fn default() -> Self {
322322
ConfigCliOptions {
323323
// Not sure about unwrap
324-
config_path: Some(dirs::config_dir().unwrap().join("onefetch/config.toml")),
324+
config_path: Some(dirs::config_dir().expect("Could not find $HOME!").join("onefetch/config.toml")),
325325
generate_config: false,
326326
}
327327
}

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl ConfigOptions {
4343
{
4444
// I dont think this can panic so i simply unwrapped it
4545
let defaults = toml::to_string(&Self::default()).unwrap();
46-
match fs::create_dir_all(&path) {
46+
match fs::create_dir_all(&path.as_ref().parent().unwrap_or(Path::new("/"))) {
4747
Ok(_) => match fs::write(&path, &defaults) {
4848
Ok(_) => {
4949
let path = path.as_ref().display();

src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use onefetch::config::ConfigOptions;
88
use onefetch::info::build_info;
99
use onefetch::ui::printer::Printer;
1010
use std::io;
11+
use std::process::exit;
1112

1213
fn main() -> Result<()> {
1314
setup_panic!();
@@ -32,7 +33,9 @@ fn main() -> Result<()> {
3233
}
3334

3435
if cli_options.config.generate_config {
35-
return ConfigOptions::write_default(cli_options.config.config_path.unwrap_or_default());
36+
// what the actual FUCK is happening here?
37+
// why default path is EMPTY?
38+
return ConfigOptions::write_default(&cli_options.config.config_path.unwrap_or_default());
3639
}
3740

3841
let config_options = ConfigOptions::read(&cli_options.config.config_path.clone().unwrap_or_default());

0 commit comments

Comments
 (0)