-
-
Notifications
You must be signed in to change notification settings - Fork 24
feat: single command mode #25
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
Conversation
- also, `util.help` was mutating; expectant saved duplicate output!
|
I think this could be done better. Allow for command aliases, like in Yargs https://github.com/yargs/yargs/blob/master/docs/advanced.md#default-commands If found sirv [dir]
# equivalent to
sirv serve [dir]
# equivalent to
sirv foo [dir]The command definition would be similar to normal command. prog.command(['serve', '$0', 'foo'], 'serving something')Seems more elegant and simple instead of |
|
Disagree, that looks awful :) Sorry, already thought about, discussed, and published. There's nothing sleeker or more concise than this: sade('sirv [dir]')
.option('-H, --host', 'Hostname to use', 'localhost')
.option('-p, --port', 'Port to use', 5000)
.action((dir, opts) => {
// ...
}) |
|
Yes, it's optional but is limiting. Oriented to one specific case. I have tons of reasons not to use Yargs, but Sade. That's why I'm sad about your way of thinking and decisions. |
|
You're missing the point. A single command binary has no commands – you're only use of the binary is the binary name itself. Why would there ever need to be an alias? That makes no sense. You also have tons of reasons to not use Sade. No one's forcing you. You must realize that all your tickets and comments in this repository have been about why design of Sade sucks, is limiting, and/or done incorrectly. Not very pleasant to try and accommodate you, I must admit. |
No, I get that :lau Just said that you could used that to introduce one more feature.
Nope, I don't. I even thought to tweet about it before a few days about why it's better.
Definitely no. Never said that it sucks or the design. And if you thinking of opening issues when you face a problem is wrong, that's bad. It's always better to open an issue and try to discuss, instead of directly sending PR or even worse mirroring/copying the package. That's how open source works for me, and some times I even waited for years until I take the thing in my hands. Anyway. 🍷 😉 |
|
Issues are never a problem, nor are discussions aiming for change! It's how those discussions are carried out & the phrasing of words that makes the difference. If this is a misinterpretation on my end, I'm sorry, but I waited for multiple instances to verify before mentioning anything. I try to give the benefit of the doubt as long as possible. For the record, this was discussed over the course of a few weeks with devs and teams who use Sade, especially those who requested this feature in the past. The PR may have been opened & merged within 24 hours, but that was only after it had already been accepted. The Here's one that's closest to what you proposed: sade('sirv')
.command('[dir]', 'Run a file server', { single: true })
.option('-H, --host', 'Hostname to use', 'localhost')
.option('-p, --port', 'Port to use', 5000)
.action(handler)While it looks and feels fine, the problem is that it's unclear how/if global settings are to be merged into the command scope (or vice versa). For example sade('sirv')
.example('public --dev') // here
.option('-c, --cors', 'Attach CORS headers') // here
.command('[dir]', 'Run a file server', { single: true })
.option('-H, --host', 'Hostname to use', 'localhost')
.option('-p, --port', 'Port to use', 5000)
.action(handler)How do the global attributes (pre- The design of Sade has always been that you set attributes on the program, as a whole, before adding commands with attributes of their own. In a tree analogy, you start with the trunk before growing a branch. Well, in "single command mode", there are no branches. It's just a program stump 😆 It's the base/global scope of your program, because that's all your program is. There are no branches because there are no avenues or routes (aka, Conceptually, this made much more sense to ~80-90% of the people I discussed this with. The "beauty" in the idea is that it was always already there, by design. We're just now highlighting it. If you're hung up on the Those examples look like this: $ bin [options]
# bin --foo --bar --bazI do not expect this to be a common use case, because it hardly makes use of any Sade features – but it's supported just in case since it's bound to show up at some point. // Example of single-bin w/o any arguments
// ~> AKA, the only time `isSingle` needs defining
sade('sirv', true)
.option('-H, --host', 'Hostname to use', 'localhost')
.option('-p, --port', 'Port to use', 5000)
.action(handler);
// Example of single-bin w/ arguments
// ~> AKA, pretty much every use case
sade('sirv [dir]')
.option('-H, --host', 'Hostname to use', 'localhost')
.option('-p, --port', 'Port to use', 5000)
.action(handler);Hope that helps shine some light on the "why" – and sorry again if I misinterpreted your tone 🍻 |
|
This feature doesn't affect me in any way, so I don't care and I'm not against it. Just discussing the way it could be introduced. Anyway, it already landed so it may not make much sense to discuss it.
Sorry my tone if there's such :D I'm never going with any tone. I don't know why everyone is assuming I'm hating or approaching with anger or bad feelings.
Sure, probably. I'm not native English and sometimes I definitely don't like the way I put it. I'm not good at that and had problems in the past because of that.
I'm not proposing that. And it definitely doesn't look good and with This feature is about when you want to have the "single command mode" behavior but have more commands - which in reality we can just call command aliases. The first example that comes to my mind is the Parcel CLI. You can
Sure thing. That's totally acceptable and I understand.
Of course, great. That's why I like Sade instead of yargs, where I should add some "builder" function or object, so to be able to add command specific options. Sade is intuitive. 🥂 |
This is the You're only allowed one Aside from that, command aliases aren't available nor planned. IMO, a command should only ever have one name. Otherwise it's very confusing, actually. |
|
Oooh, yea yea, probably. I was just reading their cli code to see what is happening there but seems like they are not using this option and are doing another magic. Yup. I don't like it either. |
Closes #2 🎉