feat: Support terminated options like find -exec#395
Open
rebornplusplus wants to merge 1 commit intojessevdk:mainfrom
Open
feat: Support terminated options like find -exec#395rebornplusplus wants to merge 1 commit intojessevdk:mainfrom
find -exec#395rebornplusplus wants to merge 1 commit intojessevdk:mainfrom
Conversation
rebornplusplus
pushed a commit
to rebornplusplus/pebble
that referenced
this pull request
Feb 8, 2023
The upstream go-flags project do not support terminated options like ``find -exec``. The repo was forked and the feature was introduced in [0]. Until the PR [1] is merged in the upstream repo, we need to maintain and point to a fork with the features there. Refs: - [0] rebornplusplus/go-flags@1dbaf44 - [1] jessevdk/go-flags#395
benhoyt
reviewed
Feb 14, 2023
benhoyt
left a comment
There was a problem hiding this comment.
The overall idea looks reasonable to me, but I have a few comments related to making it more general and cleaning it up a bit.
df1e3bf to
92578f9
Compare
Author
|
Hi @benhoyt, thanks for your comments and suggestions! I have updated the PR. Could you please take another look? |
benhoyt
approved these changes
Feb 23, 2023
benhoyt
left a comment
There was a problem hiding this comment.
Nice work! Just a couple of minor nits comments (and I kinda disagree --term \; that should be disallowed).
Enable option to receive arguments until specified terminator
is reached or EOL has been found. This is inspired from
``find -exec [commands..] ;`` where commands.. is treated as
arguments to -exec.
If for an option ``opt``, ``terminator`` is specified to be
; (semi-colon), in the following
$ program [options] --opt v --w=x -- "y z" \; [more-options]
--opt will receive {"v", "--w=x", "--", "y z"} as its
argument. Note that, the -- inside will also be passed to
--opt regardless PassDoubleDash is set or not. However,
once the scope of --opt is finished, i.e. terminator ;
is reached, -- will act as before if PassDoubleDash is set.
Use tag ``terminator`` to specify the terminator for
the option related to that field.
Please note that, the specified terminator should be a
separate token, instead of being jotted with other characters.
For example,
--opt [arguments..] ; [options..]
will be correctly parsed with terminator: ";". However,
--opt [arguments..] arg; [options..]
will not be correctly parsed. The parser will pass "arg;",
and continue to look for the terminator in [options..].
92578f9 to
18b729e
Compare
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.
feat: Support terminated options like
find -execEnable option to receive arguments until specified terminator
is reached or EOL has been found. This is inspired from
find -exec [commands..] ;where commands.. is treated asarguments to -exec.
If for an option
opt,terminatoris specified to be; (semi-colon), in the following
--opt will receive {"v", "--w=x", "--", "y z"} as its
argument. Note that, the -- inside will also be passed to
--opt regardless PassDoubleDash is set or not. However,
once the scope of --opt is finished, i.e. terminator ;
is reached, -- will act as before if PassDoubleDash is set.
Use tag
terminatorto specify the terminator forthe option related to that field.
Please note that, the specified terminator should be a
separate token, instead of being jotted with other characters.
For example,
will be correctly parsed with terminator: ";". However,
will not be correctly parsed. The parser will pass "arg;",
and continue to look for the terminator in [options..].