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

Restore multiple socket support after clap upgrade #28

Closed

Conversation

is-alnilam
Copy link
Contributor

Another impact of the update to clap is that the support for multiple copies of a parameter has changed. This means that it is currently not possible to specify multiple listening sockets.

Clap has added a feature which allows a single parameter to take multiple values, for instance -s 2000 3000 would create two listening TCP sockets. This behaviour is enabled with the Arg::num_args function when given a range.

Related to this, the Arg::number_of_values function is now a call to Arg::num_args with a single value (and as a result is deprecated).

The combination of these two factors means that the current code is first setting a range, and then overriding this with a unit value.

One option would therefore be to remove line 37 (.number_of_values(1)) although this would then need to update documentation and usages.

To restore the previous behaviour it is necessary to add a call to Arg::action, specifying to append parameters into a list. The calls to num_args and number_of_values can then be removed as the number defaults to a single value per option.

Another impact of the update to clap is that the support for multiple
copies of a parameter has changed. This means that it is currently not
possible to specify multiple listening sockets.

Clap has added a feature which allows a single parameter to take
multiple values, for instance `-s 2000 3000` would create two listening
TCP sockets. This behaviour is enabled with the `Arg::num_args` function
when given a range.

Related to this, the `Arg::number_of_values` function is now a call to
`Arg::num_args` with a single value (and as a result is deprecated).

The combination of these two factors means that the current code is
first setting a range, and then overriding this with a unit value.

One option would therefore be to remove line 37 (`.number_of_values(1)`)
although this would then need to update documentation and usages.

To restore the previous behaviour it is necessary to add a call to
`Arg::action`, specifying to append parameters into a list. The calls to
`num_args` and `number_of_values` can then be removed as the number
defaults to a single value per option.
@mitsuhiko
Copy link
Owner

Fixed

@mitsuhiko mitsuhiko closed this Sep 10, 2024
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.

2 participants