Skip to content

Commit

Permalink
[#432] Set default location for default configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
brosier01 committed Oct 15, 2024
1 parent ac89a38 commit 973c574
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ thiserror = { version = "1.0.56" }
tiny-fn = { version = "0.1.6" }
toml = { version = "0.8.13" }
tracing = { version = "0.1.40" }
dirs = { version = "5.0" }
windows-sys = { version = "0.48.0", features = ["Win32_Security", "Win32_Security_Authorization", "Win32_System_Memory", "Win32_System_Threading", "Win32_Foundation", "Win32_System_WindowsProgramming", "Win32_Storage_FileSystem", "Win32_System_IO", "Win32_System_Diagnostics_Debug", "Win32_System_SystemInformation", "Win32_System_Diagnostics_ToolHelp", "Win32_System_Console", "Win32_Networking_WinSock",
"Win32_System_SystemServices", "Win32_System_ProcessStatus"] }

Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-bb/posix/src/system_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! Provides information about the POSIX [`SystemInfo`], [`Limit`]s, available [`SysOption`] and
//! [`Feature`]s.

use enum_iterator::{all, Sequence};
use enum_iterator::Sequence;
use iceoryx2_bb_log::{fatal_panic, warn};
use iceoryx2_pal_posix::posix::Struct;
use iceoryx2_pal_posix::*;
Expand Down
1 change: 1 addition & 0 deletions iceoryx2-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ serde_yaml = { workspace = true }
serde_json = { workspace = true }
ron = { workspace = true }
toml = { workspace = true }
dirs = { workspace = true }

[dev-dependencies]
iceoryx2-bb-testing = { workspace = true }
Expand Down
10 changes: 5 additions & 5 deletions iceoryx2-cli/iox2-config/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ use anyhow::Result;
use enum_iterator::all;
use iceoryx2::config::Config;
use iceoryx2_bb_posix::system_configuration::*;
use std::fs::File;
use std::fs::{self, File};
use std::io::Write;
use std::path::Path;

/// Prints the whole system configuration with all limits, features and details to the console.
pub fn print_system_configuration() {
Expand Down Expand Up @@ -109,11 +108,12 @@ pub fn show() -> Result<()> {
}

pub fn generate() -> Result<()> {
let default_file_path = Path::new("config/iceoryx2.toml");
let config_dir = dirs::config_dir().unwrap().join("iceoryx2/");
fs::create_dir_all(&config_dir)?;

let default_config = Config::default();
let default_file_path = config_dir.join("config.toml");

let toml_string = toml::to_string_pretty(&default_config)?;
let toml_string = toml::to_string_pretty(&Config::default())?;

let mut file = File::create(&default_file_path)?;
file.write_all(toml_string.as_bytes())?;
Expand Down

0 comments on commit 973c574

Please sign in to comment.