tests/gnrc_udp: reimplement using sys/optparse.#11400
Closed
jcarrano wants to merge 20 commits intoRIOT-OS:masterfrom
Closed
tests/gnrc_udp: reimplement using sys/optparse.#11400jcarrano wants to merge 20 commits intoRIOT-OS:masterfrom
jcarrano wants to merge 20 commits intoRIOT-OS:masterfrom
Conversation
Add a generic command line parser that can be used by shell commands. This is **NOT** getopt.
- Turn macros into functions - Use DEVELHELP instead of DEBUG - Use typedefs. - Add some more comments.
The previous code wuld not accept constant argv.
LOAD_VAR renamed to LAZY_LOAD (because it loads lazily) Moved variable declarations closer to where they are used.
Unnecessary for microcontrollers, many will not even have support for it. Also saves space in the opt_rule_t structure (it was the only 8 byte member).
The handling of positional arguments was completely reworked. Also, the command line format can now be completely specified in read-only memory and initialized via static macros.
These changes produce a small but noticeable decrease in code size.
Show how optparse can be used in an existing code.
Parsers are not for validation. They are for parsing.
Contributor
|
Since the dependency PR got closed, do you think this PR should also be closed? |
Contributor
|
I think this is a yes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
Some time ago I wrote #9538 but it was lacking an example of how it can be used. Now, inspired by #11357 , I present the "optparse version" of tests/gnrc_udp.
For more information, see #9538
Testing procedure1
The module is tested in the original PR. The goal of this is just to show how code looks like when it uses sys/optparse.
Issues/PRs references
Depends on #9538.