Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iox #404 Fix verbose output and introduce CmdLineArgs_t struct #523

Merged

Conversation

mossmaurice
Copy link
Contributor

@mossmaurice mossmaurice commented Jan 27, 2021

Pre-Review Checklist for the PR Author

  1. Branch follows the naming format (iox-#123-this-is-a-branch)
  2. Commits messages are according to this guideline
    • Commit messages have the issue ID (iox-#123 commit text)
    • Commit messages are signed (git commit -s)
    • Commit author matches Eclipse Contributor Agreement (and ECA is signed)
  3. Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  4. Relevant issues are linked
  5. Add sensible notes for the reviewer
  6. All checks have passed
  7. Assign PR to reviewer

Notes for Reviewer

  • Fix output when calling ./iox-roudi --help
  • Print command line args in RouDiApp instead of in main
  • Change interface from CmdLineParser& to CmdLineArgs_t struct to make RouDi more modular
  • Add CmdLineParser* unit tests

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Code according to our coding style and naming conventions
  • Unit tests have been written for new behavior
  • Public API changes are documented via doxygen
  • Copyright owner are updated in the changed files
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

Post-review Checklist for the Eclipse Committer

  1. All checkboxes in the PR checklist are checked or crossed out
  2. Merge

References

…neParser

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
@mossmaurice mossmaurice added bugfix Solves a bug refactoring Refactor code without adding features labels Jan 27, 2021
@mossmaurice mossmaurice self-assigned this Jan 27, 2021
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
elBoberido
elBoberido previously approved these changes Feb 1, 2021
Copy link
Member

@elBoberido elBoberido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have tests for the CmdLineParser?

iceoryx_posh/source/roudi/roudi_cmd_line_parser.cpp Outdated Show resolved Hide resolved
cmdLineParser.printParameters();

IceOryxRouDiApp roudi(cmdLineParser, roudiConfig);
IceOryxRouDiApp roudi(cmdLineArgs, roudiConfig);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to only have the roudiConfig here. Ideally such things like the LogLevel could also set by TOML but the cmd line would have a higher precedence. Maybe something for another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point. For me this is related to the RouDi refactorings for safety certificiation. This epic should be started with #230

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
…st cases

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
{"kill-delay", required_argument, nullptr, 'k'},
{nullptr, 0, nullptr, 0}};

// colon after shortOption means it requires an argument, two colons mean optional argument
constexpr const char* shortOptions = "hvm:l:u:c:k:";
constexpr const char* shortOptions = "hvm:l:u:x:k:";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope this change won't lead to misfortune 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh no, the luck is gone 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, there was a clash with the --config-file option. It's a bit unfortunate that the long option doesn't start with the same letter as the short option. Maybe we can think of something that also fits and doesn't yet have a short option.

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
iceoryx_examples/iceperf/roudi_main_static_config.cpp Outdated Show resolved Hide resolved
iceoryx_posh/source/roudi/application/roudi_main.cpp Outdated Show resolved Hide resolved
{"kill-delay", required_argument, nullptr, 'k'},
{nullptr, 0, nullptr, 0}};

// colon after shortOption means it requires an argument, two colons mean optional argument
constexpr const char* shortOptions = "hvm:l:u:c:k:";
constexpr const char* shortOptions = "hvm:l:u:x:k:";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, there was a clash with the --config-file option. It's a bit unfortunate that the long option doesn't start with the same letter as the short option. Maybe we can think of something that also fits and doesn't yet have a short option.

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
orecham
orecham previously approved these changes Feb 3, 2021
Copy link
Contributor

@orecham orecham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one minor point to consider otherwise looks good.

@mossmaurice mossmaurice mentioned this pull request Feb 3, 2021
9 tasks
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
@@ -25,7 +25,12 @@ int main(int argc, char* argv[])
static constexpr uint32_t ONE_MEGABYTE = 1024U * 1024;

iox::config::CmdLineParserConfigFileOption cmdLineParser;
cmdLineParser.parse(argc, argv);
auto cmdLineArgs = cmdLineParser.parse(argc, argv);
if (cmdLineArgs.has_error() && (cmdLineArgs.get_error() != iox::config::CmdLineParserResult::INFO_OUTPUT_ONLY))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is INFO_OUTPUT_ONLY an error or success result ?

Copy link
Contributor Author

@mossmaurice mossmaurice Feb 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither an error nor a success, but something inbetween. This is why I called it CmdLineParserResult and not CmdLineParserError. We did the same for removing the optional inside a expected for the new v1.0 API. However, the methods are still called get_error(). We might consider renaming them to get_result() but that is somehow ambiguous.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... but then get_error can be a lie !

Copy link
Contributor Author

@mossmaurice mossmaurice Feb 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust uses the same terminology for Result as we currently do for the expected.

@elBoberido What's your take on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both of you are right ... and I have to leave 😁
get_unexpected might be a better name is this case, but I'm not quite sure what's in the expected proposal.
As mossmaurice pointed out, Rust does it the same way, although it would be more idiomatic to use a Result<Option<CmdLineArgs>, E> in this case.
I'm slightly leaning towards being pragmatic and keep it as it is, since we are doing the same with takeResult in the Subscriber. We could think of renaming the method, though.

@mossmaurice mossmaurice merged commit 2c0c504 into eclipse-iceoryx:master Feb 5, 2021
@marthtz marthtz mentioned this pull request Mar 5, 2021
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Solves a bug refactoring Refactor code without adding features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong handling of applications that are started multiple times in parallel
5 participants