Skip to content

Commit

Permalink
fix creating settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gofmanaa committed Aug 6, 2024
1 parent 7bcdd45 commit 59adf13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use config::{Config as ConfigBuilder, File, FileFormat};
use serde::Deserialize;
use std::{
error::Error,
fs,
io::{BufWriter, Write},
path::Path,
};
use std::{error::Error, fs, io::Write, path::Path};

#[derive(Debug, Deserialize)]
pub struct Config {
Expand Down Expand Up @@ -52,7 +47,7 @@ impl Config {
fn create_config_file(config_path: &str) -> Result<(), Box<dyn Error>> {
//create config file if it doesn't exist
if !Path::new(config_path).exists() {
let mut file = BufWriter::new(fs::File::create(config_path)?);
let mut file = fs::File::create(config_path)?;

file.write_all(
toml::toml! {
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use config::Config;
use cred_store::{CredStore, Credentials};

use clap::{arg, command, value_parser, Arg, ArgMatches};
use std::{env, panic, path::PathBuf};
use std::{env, fs, panic, path::PathBuf};

pub struct CommandContext<'a, T: CredStore> {
pub config: &'a Config,
Expand All @@ -34,6 +34,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
};

let mamoru_dir_path = home_dir.join(MAMORU_CONFIG_DIR);
if !mamoru_dir_path.exists() {
fs::create_dir_all(mamoru_dir_path.clone())?;
}
let settings_file = mamoru_dir_path.join(CONFIG_NAME);
let credentials_file = mamoru_dir_path.join(CREDENTIALS);

Expand Down

0 comments on commit 59adf13

Please sign in to comment.