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
CHG: Permit flags as both prequel or sequel of positional arguments #123
Conversation
- makes '[options]' in usage a prequel of positional in help message (more often seen in th wild, more natural to some, arguable to many) - without breaking their original behavior This make flags: - usable either before, after, or both sides of positional arguments - breaking if one appears in between two positional arguments - repeatable as they'll just overide themself, so there is no problem having same flag used in both sides of positionals. Also, this PR change behavior of missing positional argument: - original error message is kept - then a full help for subcommand is printed (exec fallback to `$0 $action -h` This is because it was found really frustrating for discovery that a subcommand with positional argument would be discoverable by iterating over errors or forcing a -h, a-contrario of nearly all other case that bashly generates. (Note : - these changes are known to be quite opiniated. - The very high robustness and coherence that bashly shows in behavior and code probably makes this PR unable to qualify for further treatment For these reason, I would not be offended if this PR is thrown away without feedback)
Thank you Colin for this PR and for your kind words. I would need to take a deeper look, and if we will be moving on with this change, fix the current tests and implement new ones for the new use cases. |
Also - I do not understand this comment of yours:
Can you give me a step by step reproduction, so I can see why it is frustrating? |
I tested the PR locally, and many of the basic bashly tests fail, for the right reasons. This PR as is, breaks some things. I am also not a big fan of showing |
This is what I meant when I said opinionated. It's even more a case of precedence than opinion on my side, since semantically your way actually feels more natural. Still it won't clear strong kinetic memory and continues to be a bit of pain. Might be the time to break some habits for me. And since it breaks much test case, let's throw this away. Thanks for your time :) (I'm closing with a longer comment on the "frustration" thing, in case it is of interest) However, after trying again the scenario, definitely this is heavy frustration to have no help/usage fallback on empty/erroneous usage of complex case. (Warning : This is definitely a case of Golang ecosystem induced frustration; yet might be interesting) e.g: cbrigato@ci:~/frusty$ cat src/bashly.yml
name: frusty
help: Apex of frustiness inner core essential self awareness
version: 0.1.0
commands:
- name: benchmarks
short: b
help: common benchmark scenario for our super project
commands:
- name: microservicea
short: msa
help: msa oriented benchmarks
commands:
- name: jobs
short: j
help: benchmark /jobs endpoint (critical for e.g. BO,Mobile APP...)
args:
- name: status
required: true
help: status of jobs for filter
allowed: [job_done,job_canceled,job_in_progress,pending_realization,pending_answer,pending_payment]
- name: per-page
required: true
help: per page job recollection limit
flags:
- long: --users
short: -u
arg: users
required: true
help: quoted or escaped, space separated list of users mail that will run each test (for jwt-dependant cases)
- long: --page
short: -g
arg: page
help: an offset of "per-page" unit base that we often see alongside pagination concepts \:)
default: 1
- name: incidents
short: i
help: benchmark /incident endpoint (critical for e.g QA, partners...) #this is example case of utility that CI and QA/humans will use, we implement shortcuts for scenarios of end to end cases and benchmarks (let say) when being even the least profane of the specific cases, there is deep contrast from start to end of discovery, or usage:
Common scenarios of frustration we received for feedback are nearly all giving the impression that bashly is at same time producing "so much user friendly" cli while suddenly lacking "very common features". I must say this is quite uncommon to have this contrast observable. if ever you got time, that asciinema shows pretty much how our guys use cli software (iterative discovery is always expected, even in failing case) if we compare with docker, for example, which is the case that probably makes much precedence, these pain points are never felt. It is quite hard to "fail" a docker command or have to rely on manually going to full help. |
Well - thanks for the asciinema demo, it helped me understand your flow, and there are a few points I want to mention:
Adding
|
@DannyBen I have no word to qualify how incredible and unexpected is your answer, not even trying to tell how much precious and rare material and attitude you're delivering here.
This is highly appreciated, but It definitely makes me curious about the case that you are seeing there that is enough to justifiy this feature : As insightful was your first semantic-powered argument, I'd definitely hear your thought once again :)
This whole PR shows that what I needed was maybe more an issue than anything else. In the end, only limitation is the flags position, everything else was available by using bashly the right way. About the frustration... I have none, this was a bit of theatrically enhanced impersonation of a some end users here. Thanks again, definitely looking for #124 ! |
Warning: Wall of text ahead Colin, first of all, thank you for your kind words. For me, it is a great pleasure discussing features and expectations with someone like you. On top of that, even if not all requests can be easily implemented, at least I learn what is it that people are looking for, and you hopefully learn why they are missing, and how they can be overcome with a slight change of perspective or design.
Well, originally when starting to develop bashly, I wanted to keep things simple, since as you can imagine, generating a valid bash script from Ruby already had its challenges. This is why I kept the command line parsing logic simple - it was (and still is) easier to first consider positional arguments, and only afterwards, parse the rest. The reason I said that I can understand the reasoning behind the desire to have support for options before positional arguments, is that this is - as you mentioned - mostly the standard in other command line frameworks, so if we can support it without complicating the code so much, it is a good feature to have.
I am curious - which other tools your are considering for your workflow?
Heh :) - I see. Well - I can totally relate. Not everybody is using the command line in the same way, and it helped me see another way that people may be expecting it to work. Now, although I always strive to have my tools behave as people expect them to, at the end of the day - as I am sure you know - its a balancing act between the code complexity and the benefits of the feature. I am sure that bashly does not solve all problems, but I hope that at least it provides the ability to develop bash scripts that almost feel like real command line tools.
As I understand, you are developing these scripts for other colleagues to use. If this is indeed the case, then I would like to reiterate a few recommendations that I am implementing with my team:
Sure thing, my pleasure. Just keep in mind that I am not yet sure that #124 can be easily developed. As we discovered, just moving the If you have other thoughts or issues, or even if you just want to share a success or failure story of your generated scripts, feel free to open new tickets. |
This make flags:
Also, this PR change behavior of missing positional argument by exec'ing self plus -h after original error
(This is because it was found really frustrating for discovery that a subcommand with positional argument would be discoverable by iterating over errors or forcing a -h,
a-contrario of nearly all other case that bashly generates.)
Note :
More than enough to not take any offense in case this PR is thrown away without any other care.
(Deep thanks for your very valuable,trustable and elegant work.)