eclipse-iceoryx / iceoryx2

Eclipse iceoryx2™ - true zero-copy inter-process-communication in pure Rust
https://iceoryx.io
Apache License 2.0
449 stars 22 forks source link

[#98] Add entrypoint for iox2 cli #106

Closed orecham closed 6 days ago

orecham commented 5 months ago

Notes for Reviewer

  1. Adds the top-level entry-point CLI for iox2
    $ ./target/debug/iox2 --help
  2. The top level CLI discovers available commands by looking for binaries with the prefix iox2- in the $PATH or in the cargo build directories
  3. Binaries that are discovered can be viewed using --list - the same as how cargo handles external binaries
    $ ./target/debug/iox2 --list
  4. The locations checked for binaries can be viewed using:
    $ ./target/debug/iox2 --paths
  5. Discovered binaries in PATH can be executed as if they were a defined sub command
    $ ./target/debug/iox2 services
  6. Discovered binaries in cargo build directories can only be executed with the flag --dev set
    $ ./target/debug/iox2 --dev services
    1. This distinction is to deal with the case where a binary with the same name is found in both the $PATH and in the build directories

Example Usage:

➜  iceoryx2 git:(iox2-98-entrypoint-for-iox2-cli) ./target/debug/iox2 --help
Usage: iox2 [OPTIONS] [COMMAND]

Options:
  -l, --list     List all installed commands
  -p, --paths    Display paths that will be checked for installed commands
  -d, --dev      Specify to execute development versions of commands if they exist
  -h, --help     Print help
  -V, --version  Print version

Commands:
  ...         See all installed commands with --list
➜  iceoryx2 git:(iox2-98-entrypoint-for-iox2-cli) ./target/debug/iox2 --paths
Development Binary Paths:
  /Users/orecham/Code/iceoryx2/target/debug

Installed Binary Paths:
  /opt/homebrew/bin
  /opt/homebrew/sbin
  /usr/local/bin
  /usr/bin
  /bin
  /usr/sbin
  /sbin
  /Users/orecham/.cargo/bin
➜  iceoryx2 git:(iox2-98-entrypoint-for-iox2-cli) ./target/debug/iox2 --list
Installed Commands:
  introspect (dev)
  processes (dev)
  pub (dev)
  rpc (dev)
  services (dev)
  sub (dev)
➜  iceoryx2 git:(iox2-98-entrypoint-for-iox2-cli) ./target/debug/iox2 --dev introspect
Not implemented. Stay tuned !

Pre-Review Checklist for the PR Author

  1. [x] Add sensible notes for the reviewer
  2. [x] PR title is short, expressive and meaningful
  3. [x] Relevant issues are linked
  4. [x] Every source code file has a copyright header with SPDX-License-Identifier: Apache-2.0 OR MIT
  5. [x] Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
  6. [x] Commits messages are according to this guideline
    • [x] Commit messages have the issue ID ([#123] Add posix ipc example)
    • [x] Commit author matches Eclipse Contributor Agreement (and ECA is signed)
  7. [x] Changelog updated in the unreleased section including API breaking changes
  8. [x] Assign PR to reviewer
  9. [x] All checks have passed (except task-list-completed)

Checklist for the PR Reviewer

Post-review Checklist for the PR Author

  1. [x] All open points are addressed and tracked via issues

References

Use either 'Closes #123' or 'Relates to #123' to reference the corresponding issue.

Relates to #98

orecham commented 5 months ago

@elBoberido @elfenpiff I am not quite finished, but could I get a preliminary review of the code to check if it is following rust conventions and idioms ?

orecham commented 1 month ago

@elBoberido

* cargo also lists some of the commands with `--help`

This would require commands to be included in the iox2 binary i.e. not be external. If implemented, these commands would be listed under Commands: before ... See all installed commands with --list

* it seems `iox2 services --help` prints the `iox2` help instead of the one from `iox2-services`

This is probably because the services binary does not include a CLI that parses the arguments. When these commands are implemented to parse the CLI, it should print the help of the specific command.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 0% with 237 lines in your changes missing coverage. Please review.

Project coverage is 78.49%. Comparing base (ad6dcd0) to head (ccbd452).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106/graphs/tree.svg?width=650&height=150&src=pr&token=FN3YFXTJCI&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx)](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx) ```diff @@ Coverage Diff @@ ## main #106 +/- ## ========================================== - Coverage 79.34% 78.49% -0.86% ========================================== Files 194 203 +9 Lines 21475 21712 +237 ========================================== + Hits 17040 17042 +2 - Misses 4435 4670 +235 ``` | [Files](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx) | Coverage Δ | | |---|---|---| | [iceoryx2-cli/iox2-introspect/src/main.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?src=pr&el=tree&filepath=iceoryx2-cli%2Fiox2-introspect%2Fsrc%2Fmain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItY2xpL2lveDItaW50cm9zcGVjdC9zcmMvbWFpbi5ycw==) | `0.00% <0.00%> (ø)` | | | [iceoryx2-cli/iox2-processes/src/main.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?src=pr&el=tree&filepath=iceoryx2-cli%2Fiox2-processes%2Fsrc%2Fmain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItY2xpL2lveDItcHJvY2Vzc2VzL3NyYy9tYWluLnJz) | `0.00% <0.00%> (ø)` | | | [iceoryx2-cli/iox2-pub/src/main.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?src=pr&el=tree&filepath=iceoryx2-cli%2Fiox2-pub%2Fsrc%2Fmain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItY2xpL2lveDItcHViL3NyYy9tYWluLnJz) | `0.00% <0.00%> (ø)` | | | [iceoryx2-cli/iox2-rpc/src/main.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?src=pr&el=tree&filepath=iceoryx2-cli%2Fiox2-rpc%2Fsrc%2Fmain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItY2xpL2lveDItcnBjL3NyYy9tYWluLnJz) | `0.00% <0.00%> (ø)` | | | [iceoryx2-cli/iox2-services/src/main.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?src=pr&el=tree&filepath=iceoryx2-cli%2Fiox2-services%2Fsrc%2Fmain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItY2xpL2lveDItc2VydmljZXMvc3JjL21haW4ucnM=) | `0.00% <0.00%> (ø)` | | | [iceoryx2-cli/iox2-sub/src/main.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?src=pr&el=tree&filepath=iceoryx2-cli%2Fiox2-sub%2Fsrc%2Fmain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItY2xpL2lveDItc3ViL3NyYy9tYWluLnJz) | `0.00% <0.00%> (ø)` | | | [iceoryx2-cli/iox2/src/cli.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?src=pr&el=tree&filepath=iceoryx2-cli%2Fiox2%2Fsrc%2Fcli.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItY2xpL2lveDIvc3JjL2NsaS5ycw==) | `0.00% <0.00%> (ø)` | | | [iceoryx2-cli/iox2/src/main.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?src=pr&el=tree&filepath=iceoryx2-cli%2Fiox2%2Fsrc%2Fmain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItY2xpL2lveDIvc3JjL21haW4ucnM=) | `0.00% <0.00%> (ø)` | | | [iceoryx2-cli/iox2/src/commands.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106?src=pr&el=tree&filepath=iceoryx2-cli%2Fiox2%2Fsrc%2Fcommands.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItY2xpL2lveDIvc3JjL2NvbW1hbmRzLnJz) | `0.00% <0.00%> (ø)` | | ... and [4 files with indirect coverage changes](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/106/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx)
orecham commented 1 month ago

@elBoberido @elfenpiff Getting a puzzling error in the mac os CI job:

error: package `clap_builder v4.5.2` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.73.0
Either upgrade to rustc 1.74 or newer, or use
cargo update -p clap_builder@4.5.2 --precise ver
where `ver` is the latest version of `clap_builder` supporting rustc 1.73.0
Error: Process completed with exit code 101.

It's puzzling because the version I specify in the Cargo.toml is not v4.5.2:

clap = { version = "4.4.18", features = ["derive"] }

Have you seen this before ?

elBoberido commented 1 month ago

@elBoberido @elfenpiff Getting a puzzling error in the mac os CI job:


error: package `clap_builder v4.5.2` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.73.0
// snip
Have you seen this before ?

It's a dependency from human-panic. You can either try an older version of human-panic or you can add default-features = false to the human-panic dependency. This will turn off the colors but also removes the dependency on clap. You could also try to convince the maintainer of anstyle and anstream to add a flag to not use clap and then ask the maintainer of human-panic to use that flag. Then continue until none of the dependencies is using clap by default :sweat_smile:

Btw, this is the relevant output of cargo tree

├── clap v4.5.4
│   ├── clap_builder v4.5.2
│   │   ├── anstream v0.6.14
│   │   │   ├── anstyle v1.0.7
│   │   │   ├── anstyle-parse v0.2.4
│   │   │   │   └── utf8parse v0.2.1
│   │   │   ├── anstyle-query v1.0.3
│   │   │   ├── colorchoice v1.0.1
│   │   │   ├── is_terminal_polyfill v1.70.0
│   │   │   └── utf8parse v0.2.1
│   │   ├── anstyle v1.0.7
│   │   ├── clap_lex v0.7.0
│   │   └── strsim v0.11.1
│   └── clap_derive v4.5.4 (proc-macro)
│       ├── heck v0.5.0
│       ├── proc-macro2 v1.0.76
│       │   └── unicode-ident v1.0.12
│       ├── quote v1.0.35
│       │   └── proc-macro2 v1.0.76 (*)
│       └── syn v2.0.48
│           ├── proc-macro2 v1.0.76 (*)
│           ├── quote v1.0.35 (*)
│           └── unicode-ident v1.0.12
orecham commented 1 month ago

It's a dependency from human-panic. You can either try an older version of human-panic or you can add default-features = false to the human-panic dependency. This will turn off the colors but also removes the dependency on clap. You could also try to convince the maintainer of anstyle and anstream to add a flag to not use clap and then ask the maintainer of human-panic to use that flag. Then continue until none of the dependencies is using clap by default 😅

@elBoberido Is it possible to increase the version of rustc in the CI Image ?

elfenpiff commented 1 month ago

It's a dependency from human-panic. You can either try an older version of human-panic or you can add default-features = false to the human-panic dependency. This will turn off the colors but also removes the dependency on clap. You could also try to convince the maintainer of anstyle and anstream to add a flag to not use clap and then ask the maintainer of human-panic to use that flag. Then continue until none of the dependencies is using clap by default 😅

@elBoberido Is it possible to increase the version of rustc in the CI Image ?

Yes, this is not a problem! I could create a separate PR and increase it to rust version 1.74 - but we can also go higher.

orecham commented 1 month ago

It's a dependency from human-panic. You can either try an older version of human-panic or you can add default-features = false to the human-panic dependency. This will turn off the colors but also removes the dependency on clap. You could also try to convince the maintainer of anstyle and anstream to add a flag to not use clap and then ask the maintainer of human-panic to use that flag. Then continue until none of the dependencies is using clap by default 😅

@elBoberido Is it possible to increase the version of rustc in the CI Image ?

Yes, this is not a problem! I could create a separate PR and increase it to rust version 1.74 - but we can also go higher.

@elfenpiff Any version 1.74 or above will make things easier for this PR. You can choose what you like. Or just let me know how to do it and I can do the PR.

Note that ubuntu_22_04_aarch64_min_version_debug has the same problem.

elfenpiff commented 1 month ago

@orecham I updated all dependencies to the newest version and upgraded the minimum rust version to 1.75. PR is merged: https://github.com/eclipse-iceoryx/iceoryx2/pull/222

So you could continue from here.

elBoberido commented 1 month ago

@elBoberido

* cargo also lists some of the commands with `--help`

This would require commands to be included in the iox2 binary i.e. not be external. If implemented, these commands would be listed under Commands: before ... See all installed commands with --list

Not necessarily. The --help call could do a --list behind the scene and either list all commands or do it similar to cargo --list and only show the most important ones like

Commands:
    introspec
    processes
    services
    ...         See all commands with --list

Not for this PR but maybe something for a follow up if you like the idea.

* it seems `iox2 services --help` prints the `iox2` help instead of the one from `iox2-services`

This is probably because the services binary does not include a CLI that parses the arguments. When these commands are implemented to parse the CLI, it should print the help of the specific command.

If I call iox2-services --help it prints Not implemented. Stay tuned !. I guess the argument is not forwarded to the command.