From 724809184a4b8be48f52b0dbf2d296be60b72230 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Sat, 21 Sep 2024 01:51:56 +0200 Subject: [PATCH] [#98] Make CLI tools a single easy-to-install crate --- Cargo.toml | 9 ++---- iceoryx2-cli/{iox2 => }/Cargo.toml | 36 +++++++++++++++++++---- iceoryx2-cli/iox2-node/Cargo.toml | 23 --------------- iceoryx2-cli/iox2-node/src/cli.rs | 8 ++--- iceoryx2-cli/iox2-node/src/commands.rs | 10 +++---- iceoryx2-cli/iox2-node/src/filter.rs | 4 +-- iceoryx2-cli/iox2-service/Cargo.toml | 23 --------------- iceoryx2-cli/iox2-service/src/cli.rs | 8 ++--- iceoryx2-cli/iox2-service/src/commands.rs | 10 +++---- iceoryx2-cli/iox2-service/src/filter.rs | 2 +- iceoryx2-cli/iox2/src/cli.rs | 2 +- iceoryx2-cli/iox2/src/lib.rs | 14 --------- iceoryx2-cli/{utils => lib}/src/cli.rs | 0 iceoryx2-cli/{utils => lib}/src/filter.rs | 0 iceoryx2-cli/{utils => lib}/src/format.rs | 0 iceoryx2-cli/{utils => lib}/src/lib.rs | 0 iceoryx2-cli/{utils => lib}/src/output.rs | 0 iceoryx2-cli/utils/Cargo.toml | 26 ---------------- 18 files changed, 56 insertions(+), 119 deletions(-) rename iceoryx2-cli/{iox2 => }/Cargo.toml (51%) delete mode 100644 iceoryx2-cli/iox2-node/Cargo.toml delete mode 100644 iceoryx2-cli/iox2-service/Cargo.toml delete mode 100644 iceoryx2-cli/iox2/src/lib.rs rename iceoryx2-cli/{utils => lib}/src/cli.rs (100%) rename iceoryx2-cli/{utils => lib}/src/filter.rs (100%) rename iceoryx2-cli/{utils => lib}/src/format.rs (100%) rename iceoryx2-cli/{utils => lib}/src/lib.rs (100%) rename iceoryx2-cli/{utils => lib}/src/output.rs (100%) delete mode 100644 iceoryx2-cli/utils/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index c53c1f15b..95145da3b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,10 +22,7 @@ members = [ "iceoryx2-pal/posix/", "iceoryx2-pal/configuration/", - "iceoryx2-cli/iox2", - "iceoryx2-cli/iox2-node", - "iceoryx2-cli/iox2-service", - "iceoryx2-cli/utils", + "iceoryx2-cli", "examples", @@ -62,8 +59,6 @@ iceoryx2-pal-concurrency-sync = { version = "0.3.0", path = "iceoryx2-pal/concur iceoryx2-pal-posix = { version = "0.3.0", path = "iceoryx2-pal/posix/" } iceoryx2-pal-configuration = { version = "0.3.0", path = "iceoryx2-pal/configuration/" } -iceoryx2-cli-utils = { version = "0.3.0", path = "iceoryx2-cli/utils/" } - iceoryx2-cal = { version = "0.3.0", path = "iceoryx2-cal" } iceoryx2-ffi = { version = "0.3.0", path = "iceoryx2-ffi/ffi" } @@ -71,6 +66,8 @@ iceoryx2-ffi-macros = { version = "0.3.0", path = "iceoryx2-ffi/ffi-macros" } iceoryx2 = { version = "0.3.0", path = "iceoryx2/" } +iceoryx2-cli = { version = "0.3.0", path = "iceoryx2_cli/"} + anyhow = { version = "1.0.86" } bindgen = { version = "0.69.4" } bitflags = { version = "2.5.0" } diff --git a/iceoryx2-cli/iox2/Cargo.toml b/iceoryx2-cli/Cargo.toml similarity index 51% rename from iceoryx2-cli/iox2/Cargo.toml rename to iceoryx2-cli/Cargo.toml index bd71143ca..5ad763383 100644 --- a/iceoryx2-cli/iox2/Cargo.toml +++ b/iceoryx2-cli/Cargo.toml @@ -1,6 +1,7 @@ [package] -name = "iox2" -description = "CLI entry-point" +name = "iceoryx2-cli" +description = "CLI tools for iceoryx2" + categories = { workspace = true } edition = { workspace = true } homepage = { workspace = true } @@ -10,15 +11,40 @@ repository = { workspace = true } rust-version = { workspace = true } version = { workspace = true } +[package.metadata] +default-run = "iox2" + +[[bin]] +name = "iox2" +path = "iox2/src/main.rs" + +[[bin]] +name = "iox2-node" +path = "iox2-node/src/main.rs" + +[[bin]] +name = "iox2-service" +path = "iox2-service/src/main.rs" + +[lib] +name = "iceoryx2_cli" +path = "lib/src/lib.rs" + [dependencies] -iceoryx2-cli-utils = { workspace = true } +iceoryx2 = { workspace = true } +iceoryx2-bb-log = { workspace = true } +iceoryx2-pal-posix = {workspace = true} anyhow = { workspace = true } better-panic = { workspace = true } -colored = { workspace = true } +cargo_metadata = { workspace = true } clap = { workspace = true } +colored = { workspace = true } human-panic = { workspace = true } -cargo_metadata = { workspace = true } +serde = { workspace = true } +serde_yaml = { workspace = true } +serde_json = { workspace = true } +ron = { workspace = true } [dev-dependencies] iceoryx2-bb-testing = { workspace = true } diff --git a/iceoryx2-cli/iox2-node/Cargo.toml b/iceoryx2-cli/iox2-node/Cargo.toml deleted file mode 100644 index 4234d753c..000000000 --- a/iceoryx2-cli/iox2-node/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "iox2-node" -description = "CLI for managing iceoryx2 nodes" -categories = { workspace = true } -edition = { workspace = true } -homepage = { workspace = true } -keywords = { workspace = true } -license = { workspace = true } -repository = { workspace = true } -rust-version = { workspace = true } -version = { workspace = true } - -[dependencies] -iceoryx2 = { workspace = true } -iceoryx2-bb-log = { workspace = true } -iceoryx2-cli-utils = { workspace = true } -iceoryx2-pal-posix = {workspace = true} - -anyhow = { workspace = true } -better-panic = { workspace = true } -clap = { workspace = true } -human-panic = { workspace = true } -serde = { workspace = true } diff --git a/iceoryx2-cli/iox2-node/src/cli.rs b/iceoryx2-cli/iox2-node/src/cli.rs index 42b270ce2..9abc6cf07 100644 --- a/iceoryx2-cli/iox2-node/src/cli.rs +++ b/iceoryx2-cli/iox2-node/src/cli.rs @@ -17,19 +17,19 @@ use clap::Parser; use clap::Subcommand; use clap::ValueEnum; -use iceoryx2_cli_utils::help_template; -use iceoryx2_cli_utils::Format; +use iceoryx2_cli::help_template; +use iceoryx2_cli::Format; use iceoryx2_pal_posix::posix::pid_t; #[derive(Parser)] #[command( - name = "iox2-nodes", + name = "iox2-node", about = "Query information about iceoryx2 nodes", long_about = None, version = env!("CARGO_PKG_VERSION"), disable_help_subcommand = true, arg_required_else_help = false, - help_template = help_template("iox2-nodes", false), + help_template = help_template("iox2 node", false), )] pub struct Cli { #[clap(subcommand)] diff --git a/iceoryx2-cli/iox2-node/src/commands.rs b/iceoryx2-cli/iox2-node/src/commands.rs index 65a42492e..f3611ee06 100644 --- a/iceoryx2-cli/iox2-node/src/commands.rs +++ b/iceoryx2-cli/iox2-node/src/commands.rs @@ -12,11 +12,11 @@ use anyhow::{Context, Error, Result}; use iceoryx2::prelude::*; -use iceoryx2_cli_utils::output::NodeDescription; -use iceoryx2_cli_utils::output::NodeDescriptor; -use iceoryx2_cli_utils::output::NodeList; -use iceoryx2_cli_utils::Filter; -use iceoryx2_cli_utils::Format; +use iceoryx2_cli::output::NodeDescription; +use iceoryx2_cli::output::NodeDescriptor; +use iceoryx2_cli::output::NodeList; +use iceoryx2_cli::Filter; +use iceoryx2_cli::Format; use crate::cli::NodeIdentifier; use crate::cli::OutputFilter; diff --git a/iceoryx2-cli/iox2-node/src/filter.rs b/iceoryx2-cli/iox2-node/src/filter.rs index c24f549ec..f76997e37 100644 --- a/iceoryx2-cli/iox2-node/src/filter.rs +++ b/iceoryx2-cli/iox2-node/src/filter.rs @@ -16,8 +16,8 @@ use crate::cli::StateFilter; use iceoryx2::node::NodeState; use iceoryx2::node::NodeView; use iceoryx2::service::ipc::Service; -use iceoryx2_cli_utils::output::NodeIdString; -use iceoryx2_cli_utils::Filter; +use iceoryx2_cli::output::NodeIdString; +use iceoryx2_cli::Filter; impl Filter> for NodeIdentifier { fn matches(&self, node: &NodeState) -> bool { diff --git a/iceoryx2-cli/iox2-service/Cargo.toml b/iceoryx2-cli/iox2-service/Cargo.toml deleted file mode 100644 index d93a6ba01..000000000 --- a/iceoryx2-cli/iox2-service/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "iox2-service" -description = "CLI for managing iceoryx2 services" -categories = { workspace = true } -edition = { workspace = true } -homepage = { workspace = true } -keywords = { workspace = true } -license = { workspace = true } -repository = { workspace = true } -rust-version = { workspace = true } -version = { workspace = true } - -[dependencies] -iceoryx2 = { workspace = true } -iceoryx2-bb-log = { workspace = true } -iceoryx2-cli-utils = { workspace = true } - -anyhow = { workspace = true } -better-panic = { workspace = true } -clap = { workspace = true } -human-panic = { workspace = true } -serde = { workspace = true } - diff --git a/iceoryx2-cli/iox2-service/src/cli.rs b/iceoryx2-cli/iox2-service/src/cli.rs index 7d89e5fce..e812a73da 100644 --- a/iceoryx2-cli/iox2-service/src/cli.rs +++ b/iceoryx2-cli/iox2-service/src/cli.rs @@ -15,18 +15,18 @@ use clap::Parser; use clap::Subcommand; use clap::ValueEnum; -use iceoryx2_cli_utils::help_template; -use iceoryx2_cli_utils::Format; +use iceoryx2_cli::help_template; +use iceoryx2_cli::Format; #[derive(Parser)] #[command( - name = "iox2-services", + name = "iox2-service", about = "Query information about iceoryx2 services", long_about = None, version = env!("CARGO_PKG_VERSION"), disable_help_subcommand = true, arg_required_else_help = false, - help_template = help_template("iox2-services", false), + help_template = help_template("iox2 service", false), )] pub struct Cli { #[clap(subcommand)] diff --git a/iceoryx2-cli/iox2-service/src/commands.rs b/iceoryx2-cli/iox2-service/src/commands.rs index 96294ad72..5c7be8eb9 100644 --- a/iceoryx2-cli/iox2-service/src/commands.rs +++ b/iceoryx2-cli/iox2-service/src/commands.rs @@ -12,11 +12,11 @@ use anyhow::{Context, Error, Result}; use iceoryx2::prelude::*; -use iceoryx2_cli_utils::output::ServiceDescription; -use iceoryx2_cli_utils::output::ServiceDescriptor; -use iceoryx2_cli_utils::output::ServiceList; -use iceoryx2_cli_utils::Filter; -use iceoryx2_cli_utils::Format; +use iceoryx2_cli::output::ServiceDescription; +use iceoryx2_cli::output::ServiceDescriptor; +use iceoryx2_cli::output::ServiceList; +use iceoryx2_cli::Filter; +use iceoryx2_cli::Format; use crate::cli::OutputFilter; diff --git a/iceoryx2-cli/iox2-service/src/filter.rs b/iceoryx2-cli/iox2-service/src/filter.rs index 88a5d70d0..e3550cdc7 100644 --- a/iceoryx2-cli/iox2-service/src/filter.rs +++ b/iceoryx2-cli/iox2-service/src/filter.rs @@ -15,7 +15,7 @@ use crate::cli::OutputFilter; use iceoryx2::service::ipc::Service; use iceoryx2::service::static_config::messaging_pattern::MessagingPattern; use iceoryx2::service::ServiceDetails; -use iceoryx2_cli_utils::Filter; +use iceoryx2_cli::Filter; impl Filter> for MessagingPatternFilter { fn matches(&self, service: &ServiceDetails) -> bool { diff --git a/iceoryx2-cli/iox2/src/cli.rs b/iceoryx2-cli/iox2/src/cli.rs index d55ac5a77..6024f572e 100644 --- a/iceoryx2-cli/iox2/src/cli.rs +++ b/iceoryx2-cli/iox2/src/cli.rs @@ -12,7 +12,7 @@ use clap::Parser; -use iceoryx2_cli_utils::help_template; +use iceoryx2_cli::help_template; #[derive(Parser, Debug)] #[command( diff --git a/iceoryx2-cli/iox2/src/lib.rs b/iceoryx2-cli/iox2/src/lib.rs deleted file mode 100644 index 1ae96d624..000000000 --- a/iceoryx2-cli/iox2/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -// 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 - -pub mod cli; -pub mod commands; diff --git a/iceoryx2-cli/utils/src/cli.rs b/iceoryx2-cli/lib/src/cli.rs similarity index 100% rename from iceoryx2-cli/utils/src/cli.rs rename to iceoryx2-cli/lib/src/cli.rs diff --git a/iceoryx2-cli/utils/src/filter.rs b/iceoryx2-cli/lib/src/filter.rs similarity index 100% rename from iceoryx2-cli/utils/src/filter.rs rename to iceoryx2-cli/lib/src/filter.rs diff --git a/iceoryx2-cli/utils/src/format.rs b/iceoryx2-cli/lib/src/format.rs similarity index 100% rename from iceoryx2-cli/utils/src/format.rs rename to iceoryx2-cli/lib/src/format.rs diff --git a/iceoryx2-cli/utils/src/lib.rs b/iceoryx2-cli/lib/src/lib.rs similarity index 100% rename from iceoryx2-cli/utils/src/lib.rs rename to iceoryx2-cli/lib/src/lib.rs diff --git a/iceoryx2-cli/utils/src/output.rs b/iceoryx2-cli/lib/src/output.rs similarity index 100% rename from iceoryx2-cli/utils/src/output.rs rename to iceoryx2-cli/lib/src/output.rs diff --git a/iceoryx2-cli/utils/Cargo.toml b/iceoryx2-cli/utils/Cargo.toml deleted file mode 100644 index 038e92372..000000000 --- a/iceoryx2-cli/utils/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "iceoryx2-cli-utils" -description = "Common helpers for iceoryx2 CLI tools." -categories = { workspace = true } -edition = { workspace = true } -homepage = { workspace = true } -keywords = { workspace = true } -license = { workspace = true } -repository = { workspace = true } -rust-version = { workspace = true } -version = { workspace = true } - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iceoryx2 = { workspace = true } -iceoryx2-pal-posix = {workspace = true} - -anyhow = { workspace = true } -clap = { workspace = true } -colored = { workspace = true } -toml = { workspace = true } -serde = { workspace = true } -serde_yaml = { workspace = true } -serde_json = { workspace = true } -ron = { workspace = true }