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
RFC: Allow subcommands in MAIN #688
Conversation
Perl6 was GNU-like in that it has '--double-dashes' and that it stops interpreting named parameters when it encounters '--', but unlike GNU-like parsing, it also stopped interpreting named parameters when encountering any positional argument. This patch makes it a bit more GNU-like by allowing named arguments after a positional, to prepare for allowing subcommands.
Assuming that positional literal strings at the beginning of a signature are subcommands, they go before any named arguments.
|
Demonstration: |
|
Yes yes yes! That's a very good idea 👍 . |
|
I'm afraid merging this will have to wait until we have a decision on how to technically handle versioning |
|
I understand that merging might have to wait on that decision. In the meantime, it remains important that we discuss whether we WANT to merge it, since it would require a spec change. |
|
As far as I can tell the only person who has been against this sort of change at all is Tim Toady. |
|
Can this be considered for inclusion in 2016.03 under |
|
TimToady would need to rule on the language design issue. I suspect it On Mon, Feb 22, 2016 at 6:22 PM, Jake Russo notifications@github.com
|
|
It may be a bit too late but: YES!! |
|
What if there should be a distinction between global and subcommand specific options as in: |
|
👍 Would be cool if we could also sub MAIN($ where 'foo'|'bar', :$baz) { ... } # PS why can't we just write sub MAIN('foo'|'bar',...)
Usage:
gitlike.pl [ foo | bar ] [-baz]@niner I cannot think of a way to describe main options and subcommand options with signatures |
|
Idea: what about for global switches we introspect the dispatcher's signature: Then the help could look like: Options:
-v verbose output
Usage:
zypper [OPTIONS] search <target> [--match-exact]What I'm suggesting is all cosmetic so I think @niner's concern above can be addressed after this is merged. |
|
Can someone explain what the next steps are in the process of reaching a decision? |
Does this PR break any of the current tests? If yes,Write your proposal into https://github.com/perl6/specs/blob/master/v6d.pod , listing yourself as stakeholder. The change will be considered for inclusion in the next language release. Note that that won't happen in a near future (I saw dates named anywhere for summer 2017 to Diwalli 2017, which is sometime in October). If no tests break,Then hunt down TimToady and ask him to make a decision on whether this language design change is OK. If he agrees, fix merge conflicts, and ping one of the people who can merge to merge. Hope that helps. |
The combination of these two patches will allow subcommands like in "git" or "apt".
Note that f8227bb deliberately goes against spec (S06), which says:
S06 is demonstrably wrong in that this would be the usual thing, since all these standard tools apparently take switches after positionals:
1;0 juerd@cxie:~$ wc$(ls $ (which perl6 -a) -1) --chars
26876 /home/juerd/.rakudobrew/bin/perl6
Requiring switches at the beginning is common with BSD-style command line parsing, but that style doesn't have --long-names or --, both of which are already supported by Perl 6.
This patch set has not yet been thoroughly tested. Please discuss and test :-)