diff --git a/README.md b/README.md
index 25087947f..b1b8b6880 100644
--- a/README.md
+++ b/README.md
@@ -380,6 +380,10 @@ The support levels can be adjusted when required.
![xieyuschen](https://avatars.githubusercontent.com/u/52945328)
»xieyuschen«
+
+
+ ![Bruce »brosier01« Rosier](https://avatars.githubusercontent.com/u/71630425?v=4)
+ Bruce »brosier01« Rosier |
diff --git a/doc/release-notes/iceoryx2-unreleased.md b/doc/release-notes/iceoryx2-unreleased.md
index 20261165a..a0da9e98d 100644
--- a/doc/release-notes/iceoryx2-unreleased.md
+++ b/doc/release-notes/iceoryx2-unreleased.md
@@ -6,57 +6,23 @@
### Features
-
+Create a new CLI for iceoryx2 `iox2-config`
-* Example text [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)
+`iox2-config` can `show` the configuration currently in use and `generate` a new
+configuration file at the default location iceoryx2 is looking for.
-### Bugfixes
-
-
-
-* Example text [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)
+* Add CLI to display complete system configuration [#432](https://github.com/eclipse-iceoryx/iceoryx2/issues/432)
### Refactoring
-
-
-* Example text [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)
-
-### Workflow
-
-
-
-* Example text [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)
-
-### New API features
-
-
-
-* Example text [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)
-
-### API Breaking Changes
+Remove the `print_system_configuration()` function in
+`iceoryx2-bb/posix/src/system_configuration.rs` file and move it into the CLI `iox2-config`
+[#432](https://github.com/eclipse-iceoryx/iceoryx2/issues/432)
-1. Example
+### New CLI features
- ```rust
- // old
- let fuu = hello().is_it_me_you_re_looking_for()
+```bash
+ cargo run --bin iox2-config show
- // new
- let fuu = hypnotoad().all_glory_to_the_hypnotoad()
- ```
+ cargo run --bin iox2-config generate
+```
diff --git a/iceoryx2-bb/posix/src/system_configuration.rs b/iceoryx2-bb/posix/src/system_configuration.rs
index 27a516298..dd49f825b 100644
--- a/iceoryx2-bb/posix/src/system_configuration.rs
+++ b/iceoryx2-bb/posix/src/system_configuration.rs
@@ -294,87 +294,3 @@ impl ProcessResourceLimit {
true
}
}
-
-/// Prints the whole system configuration with all limits, features and details to the console.
-pub fn print_system_configuration() {
- const HEADER_COLOR: &str = "\x1b[4;92m";
- const VALUE_COLOR: &str = "\x1b[0;94m";
- const DISABLED_VALUE_COLOR: &str = "\x1b[0;90m";
- const ENTRY_COLOR: &str = "\x1b[0;37m";
- const DISABLED_ENTRY_COLOR: &str = "\x1b[0;90m";
- const COLOR_RESET: &str = "\x1b[0m";
-
- println!("{}posix system configuration{}", HEADER_COLOR, COLOR_RESET);
- println!();
- println!(" {}system info{}", HEADER_COLOR, COLOR_RESET);
- for i in all::().collect::>() {
- println!(
- " {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
- format!("{:?}", i),
- i.value(),
- );
- }
-
- println!();
- println!(" {}limits{}", HEADER_COLOR, COLOR_RESET);
- for i in all::().collect::>() {
- let limit = i.value();
- let limit = if limit == 0 {
- "[ unlimited ]".to_string()
- } else {
- limit.to_string()
- };
- println!(
- " {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
- format!("{:?}", i),
- limit,
- );
- }
-
- println!();
- println!(" {}options{}", HEADER_COLOR, COLOR_RESET);
- for i in all::().collect::>() {
- if i.is_available() {
- println!(
- " {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
- format!("{:?}", i),
- i.is_available(),
- );
- } else {
- println!(
- " {DISABLED_ENTRY_COLOR}{:<50}{COLOR_RESET} {DISABLED_VALUE_COLOR}{}{COLOR_RESET}",
- format!("{:?}", i),
- i.is_available(),
- );
- }
- }
-
- println!();
- println!(" {}features{}", HEADER_COLOR, COLOR_RESET);
- for i in all::().collect::>() {
- if i.is_available() {
- println!(
- " {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
- format!("{:?}", i),
- i.is_available(),
- );
- } else {
- println!(
- " {DISABLED_ENTRY_COLOR}{:<50}{COLOR_RESET} {DISABLED_VALUE_COLOR}{}{COLOR_RESET}",
- format!("{:?}", i),
- i.is_available(),
- );
- }
- }
-
- println!();
- println!(" {}process resource limits{}", HEADER_COLOR, COLOR_RESET);
- for i in all::().collect::>() {
- println!(
- " {ENTRY_COLOR}{:<43}{COLOR_RESET} soft: {VALUE_COLOR}{:<24}{COLOR_RESET} hard: {VALUE_COLOR}{}{COLOR_RESET}",
- format!("{:?}", i),
- i.soft_limit(),
- i.hard_limit()
- );
- }
-}
diff --git a/iceoryx2-cli/Cargo.toml b/iceoryx2-cli/Cargo.toml
index 5ad763383..1411eccb2 100644
--- a/iceoryx2-cli/Cargo.toml
+++ b/iceoryx2-cli/Cargo.toml
@@ -26,6 +26,10 @@ path = "iox2-node/src/main.rs"
name = "iox2-service"
path = "iox2-service/src/main.rs"
+[[bin]]
+name = "iox2-config"
+path = "iox2-config/src/main.rs"
+
[lib]
name = "iceoryx2_cli"
path = "lib/src/lib.rs"
@@ -34,17 +38,22 @@ path = "lib/src/lib.rs"
iceoryx2 = { workspace = true }
iceoryx2-bb-log = { workspace = true }
iceoryx2-pal-posix = {workspace = true}
+iceoryx2-bb-posix = {workspace = true}
+iceoryx2-bb-system-types = { workspace = true }
+iceoryx2-bb-container ={ workspace = true }
anyhow = { workspace = true }
better-panic = { workspace = true }
cargo_metadata = { workspace = true }
clap = { workspace = true }
colored = { workspace = true }
+enum-iterator = { workspace = true }
human-panic = { workspace = true }
serde = { workspace = true }
serde_yaml = { workspace = true }
serde_json = { workspace = true }
ron = { workspace = true }
+toml = { workspace = true }
[dev-dependencies]
iceoryx2-bb-testing = { workspace = true }
diff --git a/iceoryx2-cli/iox2-config/src/cli.rs b/iceoryx2-cli/iox2-config/src/cli.rs
new file mode 100644
index 000000000..d6af1c26e
--- /dev/null
+++ b/iceoryx2-cli/iox2-config/src/cli.rs
@@ -0,0 +1,39 @@
+// Copyright (c) 2024 Contributors to the Eclipse Foundation
+//
+// See the NOTICE file(s) distributed with this work for additional
+// information regarding copyright ownership.
+//
+// This program and the accompanying materials are made available under the
+// terms of the Apache Software License 2.0 which is available at
+// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
+// which is available at https://opensource.org/licenses/MIT.
+//
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+use clap::Parser;
+use clap::Subcommand;
+
+use iceoryx2_cli::help_template;
+
+#[derive(Parser)]
+#[command(
+ name = "iox2-config",
+ about = "Query information about iceoryx2 configuration",
+ long_about = None,
+ version = env!("CARGO_PKG_VERSION"),
+ disable_help_subcommand = true,
+ arg_required_else_help = false,
+ help_template = help_template("iox2 config", false),
+)]
+pub struct Cli {
+ #[clap(subcommand)]
+ pub action: Option,
+}
+
+#[derive(Subcommand)]
+pub enum Action {
+ #[clap(about = "Show the currently used configuration")]
+ Show,
+ #[clap(about = "Generate a default configuration file")]
+ Generate,
+}
diff --git a/iceoryx2-cli/iox2-config/src/commands.rs b/iceoryx2-cli/iox2-config/src/commands.rs
new file mode 100644
index 000000000..5967bf1ed
--- /dev/null
+++ b/iceoryx2-cli/iox2-config/src/commands.rs
@@ -0,0 +1,127 @@
+// Copyright (c) 2024 Contributors to the Eclipse Foundation
+//
+// See the NOTICE file(s) distributed with this work for additional
+// information regarding copyright ownership.
+//
+// This program and the accompanying materials are made available under the
+// terms of the Apache Software License 2.0 which is available at
+// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
+// which is available at https://opensource.org/licenses/MIT.
+//
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+use anyhow::Result;
+use enum_iterator::all;
+use iceoryx2::config::Config;
+use iceoryx2_bb_posix::system_configuration::*;
+use std::fs::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() {
+ const HEADER_COLOR: &str = "\x1b[4;92m";
+ const VALUE_COLOR: &str = "\x1b[0;94m";
+ const DISABLED_VALUE_COLOR: &str = "\x1b[0;90m";
+ const ENTRY_COLOR: &str = "\x1b[0;37m";
+ const DISABLED_ENTRY_COLOR: &str = "\x1b[0;90m";
+ const COLOR_RESET: &str = "\x1b[0m";
+
+ println!("{}posix system configuration{}", HEADER_COLOR, COLOR_RESET);
+ println!();
+ println!(" {}system info{}", HEADER_COLOR, COLOR_RESET);
+ for i in all::().collect::>() {
+ println!(
+ " {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
+ format!("{:?}", i),
+ i.value(),
+ );
+ }
+
+ println!();
+ println!(" {}limits{}", HEADER_COLOR, COLOR_RESET);
+ for i in all::().collect::>() {
+ let limit = i.value();
+ let limit = if limit == 0 {
+ "[ unlimited ]".to_string()
+ } else {
+ limit.to_string()
+ };
+ println!(
+ " {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
+ format!("{:?}", i),
+ limit,
+ );
+ }
+
+ println!();
+ println!(" {}options{}", HEADER_COLOR, COLOR_RESET);
+ for i in all::().collect::>() {
+ if i.is_available() {
+ println!(
+ " {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
+ format!("{:?}", i),
+ i.is_available(),
+ );
+ } else {
+ println!(
+ " {DISABLED_ENTRY_COLOR}{:<50}{COLOR_RESET} {DISABLED_VALUE_COLOR}{}{COLOR_RESET}",
+ format!("{:?}", i),
+ i.is_available(),
+ );
+ }
+ }
+
+ println!();
+ println!(" {}features{}", HEADER_COLOR, COLOR_RESET);
+ for i in all::().collect::>() {
+ if i.is_available() {
+ println!(
+ " {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
+ format!("{:?}", i),
+ i.is_available(),
+ );
+ } else {
+ println!(
+ " {DISABLED_ENTRY_COLOR}{:<50}{COLOR_RESET} {DISABLED_VALUE_COLOR}{}{COLOR_RESET}",
+ format!("{:?}", i),
+ i.is_available(),
+ );
+ }
+ }
+
+ println!();
+ println!(" {}process resource limits{}", HEADER_COLOR, COLOR_RESET);
+ for i in all::().collect::>() {
+ println!(
+ " {ENTRY_COLOR}{:<43}{COLOR_RESET} soft: {VALUE_COLOR}{:<24}{COLOR_RESET} hard: {VALUE_COLOR}{}{COLOR_RESET}",
+ format!("{:?}", i),
+ i.soft_limit(),
+ i.hard_limit()
+ );
+ }
+}
+
+pub fn show() -> Result<()> {
+ print_system_configuration();
+
+ Ok(())
+}
+
+pub fn generate() -> Result<()> {
+ let default_file_path = Path::new("config/iceoryx2.toml");
+
+ let default_config = Config::default();
+
+ let toml_string = toml::to_string_pretty(&default_config)?;
+
+ let mut file = File::create(&default_file_path)?;
+ file.write_all(toml_string.as_bytes())?;
+
+ println!(
+ "Default configuration is generated at {}",
+ default_file_path.display()
+ );
+
+ Ok(())
+}
diff --git a/iceoryx2-cli/iox2-config/src/main.rs b/iceoryx2-cli/iox2-config/src/main.rs
new file mode 100644
index 000000000..178377d83
--- /dev/null
+++ b/iceoryx2-cli/iox2-config/src/main.rs
@@ -0,0 +1,66 @@
+// Copyright (c) 2024 Contributors to the Eclipse Foundation
+//
+// See the NOTICE file(s) distributed with this work for additional
+// information regarding copyright ownership.
+//
+// This program and the accompanying materials are made available under the
+// terms of the Apache Software License 2.0 which is available at
+// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
+// which is available at https://opensource.org/licenses/MIT.
+//
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+mod cli;
+mod commands;
+
+use clap::CommandFactory;
+use clap::Parser;
+use cli::Action;
+use cli::Cli;
+use iceoryx2_bb_log::{set_log_level, LogLevel};
+
+#[cfg(not(debug_assertions))]
+use human_panic::setup_panic;
+#[cfg(debug_assertions)]
+extern crate better_panic;
+
+fn main() {
+ #[cfg(not(debug_assertions))]
+ {
+ setup_panic!();
+ }
+ #[cfg(debug_assertions)]
+ {
+ better_panic::Settings::debug()
+ .most_recent_first(false)
+ .lineno_suffix(true)
+ .verbosity(better_panic::Verbosity::Full)
+ .install();
+ }
+
+ set_log_level(LogLevel::Warn);
+
+ match Cli::try_parse() {
+ Ok(cli) => {
+ if let Some(action) = cli.action {
+ match action {
+ Action::Show => {
+ if let Err(e) = commands::show() {
+ eprintln!("Failed to show options: {}", e);
+ }
+ }
+ Action::Generate => {
+ if let Err(e) = commands::generate() {
+ eprintln!("Failed to generate default configuration: {}", e);
+ }
+ }
+ }
+ } else {
+ Cli::command().print_help().expect("Failed to print help");
+ }
+ }
+ Err(e) => {
+ eprintln!("{}", e);
+ }
+ }
+}