-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Proper handling and forwarding of --flags
#100
Comments
👍
…On 9 Feb 2017 17:20, "Kent C. Dodds" ***@***.***> wrote:
Right now you can do:
nps foo --bar
And p-s will run the script called foo with the flag called --bar
However if you run:
nps foo --silent --bar
then p-s will run the script called foo with the flag called --bar but
without the flag called --silent. This is because of this
<https://github.com/kentcdodds/p-s/blob/3566a15b991d6b84e7386bd18b0e08c2e94c6235/src/bin-utils/index.js#L113-L124>
.
Normally it's not a huge deal. I think that's confusing.
Here are a few possible solutions (all of them are breaking):
1. Only accept p-s flags before the scripts (so you'd have to do nps
--silent foo --bar)
2. Require -- before the scripts and flags (nps --silent -- foo --bar)
3. Forward all flags whether they're p-s related or not (nps foo
--silent --bar and forwards --silent and --bar both)
I can't think of a way to change this behavior without breaking things.
My favorite solution is the first. Mostly because it's least noisy and
seems to make the most sense.
I'm working on #70 <#70> right
now and will make this a part of that PR. I want feedback on this really
quick. If anyone has any ideas let me know. If you'd like to vote for one
or the other use github reactions to vote: 👍 for 1, 😄 for 2, 🎉 for 3,
and 😕 for "I don't know/care"
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#100>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB4Pj62ux-u7RTubw7WCg_0WbfHeYLjIks5ra0rsgaJpZM4L8alr>
.
|
Actually, yargs has a pretty sweet API for this. I think we'll do things in a way that's mostly backward compatible. If you want to forward flags into commands, you'll have to put those commands in quotes. This will make the most sense I think! |
@kentcdodds But do you think it would look a clean syntax? nps 'build --foo' My 2 cents: I would still prefer to not have any special syntax for my cli commands and below would be better than above: nps build --foo |
Yeah, I can see how the syntax looks much cleaner. As I described though, the problem is that there's no way to know whether the user intends for the command to be passed to I think that this is a situation where explicit is better. Most of the time I expect that people don't pass flags via the command line directly and the flags happen inside the |
Actually, I've been wrestling with this a lot because I actually realized that I pass flags/arguments to So here's a proposal:
I'm not a huge fan of this either. I'm really unsure of what to do here because I don't want to make things confusing, but I want them to be ergonomic. Right now I think we favor economics to clear. Maybe we should just leave things as they are... 🤔 |
I think we're just going to require the quotes. But I'm going to add option validation so if you try |
Even though I would have preferred no-quotes, but I see your point now. But adding the error for no quotes should definitely be more consistent 👍 |
Right now you can do:
nps foo --bar
And
p-s
will run the script calledfoo
with the flag called--bar
However if you run:
nps foo --silent --bar
then
p-s
will run the script calledfoo
with the flag called--bar
but without the flag called--silent
. This is because of this.Normally it's not a huge deal. I think that's confusing.
Here are a few possible solutions (all of them are breaking):
p-s
flags before the scripts (so you'd have to donps --silent foo --bar
)--
before the scripts and flags (nps --silent -- foo --bar
)p-s
related or not (nps foo --silent --bar
and forwards--silent
and--bar
both)I can't think of a way to change this behavior without breaking things.
My favorite solution is the first. Mostly because it's least noisy and seems to make the most sense.
I'm working on #70 right now and will make this a part of that PR. I want feedback on this really quick. If anyone has any ideas let me know. If you'd like to vote for one or the other use github reactions to vote: 👍 for 1, 😄 for 2, 🎉 for 3, and 😕 for "I don't know/care"
The text was updated successfully, but these errors were encountered: