positional .strict() without requiring "--"? #364
Unanswered
jamesyoungman
asked this question in
Q&A
Replies: 2 comments 5 replies
-
You can try using |
Beta Was this translation helpful? Give feedback.
2 replies
-
Do you have the code available online? I can take a look at it.
…On Wed, Jun 26, 2024, 13:41 James Youngman ***@***.***> wrote:
No, that doesn't work correctly for the same reason I stated above ("On
the other hand..."). Specifically that the final -H in
-H -LPH -D tree -PL /tmp /var/tmp -H is treated as an option, while it
should actually be treated as a positional argument (as it is to the right
of another positional argument, /var/tmp).
IOW, run_inner actually returns
Ok(
(
H,
DebugOptions {
values: {
Tree,
},
},
[
"/tmp",
"/var/tmp",
],
),
)
but it should return
Ok(
(
L,
DebugOptions {
values: {
Tree,
},
},
[
"/tmp",
"/var/tmp",
"-H",
],
),
)
—
Reply to this email directly, view it on GitHub
<#364 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAQFI4RJKOFF2PGALT4ZPTZJL4LHAVCNFSM6AAAAABJZSEP2GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TQOBVGY3DO>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to parse the initial options of "find" (-H, -L, -P, -E, -D) and return the remaining options for later processing. I tried this:
However, this is not correct as the use of ".stirct()" means that positional args are only recognised on the right of "--" which find must not require.
On the other hand, if I remove .struct, then " find -H -LPH -D tree -PL /tmp -H" incorrectly parses the final -H as an option instead of as a positional argument.
In case you're not already familiar with find, the -H -P and -L options all mutually override each other (they select a mode, basically). The -D option is additive (so -D tree,search and -D tree -D search have the same effect). Option processing should stop at the leftmost positional argument. After that there are positional arguments which may start with a "-". For example, -print and -name.
FWIW, the "find" example in the crate docs looks like it's irrelevant as it doesn't preserve the order of evaluation, as far as I can tell, and doesn't support these (HLPDE) options either.
Beta Was this translation helpful? Give feedback.
All reactions