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

Adding command line arguments for Kotlin examples #58

Merged
merged 35 commits into from
Apr 15, 2024

Conversation

DariusIMP
Copy link
Member

Using Clickt to allow users to specify arguments when running examples on Kotlin.

Usage

For instance the ZPub example, you run it using gradle, and providing the arguments the following way:

gradle ZPub --args="<your arguments>"

** Example: **

gradle ZPub --args="-h"

will display the help menu with the available arguments:

> Task :examples:ZPub
Usage: zpub [<options>]

  Zenoh Pub example

Options:
  -e, --connect=<connect>  Endpoints to connect to.
  -c, --config=<config>    A configuration file.
  -k, --key=<key>          The key expression to write to [default:
                           demo/example/zenoh-kotlin-pub]
  -l, --listen=<listen>    Endpoints to listen on.
  -m, --mode=<mode>        The session mode. Default: peer. Possible values:
                           [peer, client, router]
  -v, --value=<value>      The value to write. [Default: "Pub from Kotlin!"]
  -a, --attach=<attach>    The attachments to add to each put. The key-value
                           pairs are &-separated, and = serves as the separator
                           between key and value.
  --no-multicast-scouting  Disable the multicast-based scouting mechanism.
  -h, --help               Show this message and exit

Solves #55

@eclipse-zenoh-bot
Copy link
Contributor

@DariusIMP If this pull request contains a bugfix or a new feature, then please consider using Closes #ISSUE-NUMBER syntax to link it to an issue.

@DariusIMP DariusIMP marked this pull request as ready for review March 15, 2024 14:04
@DariusIMP DariusIMP marked this pull request as draft March 15, 2024 14:04
@DariusIMP DariusIMP marked this pull request as ready for review March 15, 2024 14:29
@oteffahi
Copy link
Contributor

oteffahi commented Mar 22, 2024

gradle ZPub --args="-l tcp/127.0.0.1:7447 -l udp/127.0.0.1:7447" will only listen on UDP port.

As it is, a repeated flag will overwrite itself, so only the last instance counts. For list options (-l, -e), it would be good if we can repeat the flag for each value, as some users are already used to this syntax on Zenoh Rust examples (which support both syntaxes). If we dont support it here, repeating a flag multiple times should error-out to avoid unintended configuration.

… listen and connect arguments.

For instance:

  gradle ZPub --args="-l tcp/localhost:7447 tcp/localhost:7448 tcp/localhost:7449"

now becomes

  gradle ZPub --args="-l tcp/localhost:7447 -l tcp/localhost:7448 -l tcp/localhost:7449"
@DariusIMP
Copy link
Member Author

gradle ZPub --args="-l tcp/127.0.0.1:7447 -l udp/127.0.0.1:7447" will only listen on UDP port.

As it is, a repeated flag will overwrite itself, so only the last instance counts. For list options (-l, -e), it would be good if we can repeat the flag for each value, as some users are already used to this syntax on Zenoh Rust examples (which support both syntaxes). If we dont support it here, repeating a flag multiple times should error-out to avoid unintended configuration.

I just fixed it.

Copy link
Contributor

@oteffahi oteffahi left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Mallets Mallets enabled auto-merge (squash) April 15, 2024 13:26
@Mallets Mallets merged commit cfa5135 into eclipse-zenoh:main Apr 15, 2024
6 checks passed
@Mallets Mallets deleted the clikt branch April 15, 2024 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants