-
Notifications
You must be signed in to change notification settings - Fork 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
Feature request: Allow converting camelcase/snake-case proc arguments to standard Unix-style long options #28
Comments
This is already handled and mentioned in my It isn't spelled out to the command user in the help message (that label is just whatever the If you want to describe more syntax than my default to command users then you can just pass usage="my more verbose help template instead of "${prelude}$command $args\n$doc Options(opt-arg sep :|=|spc):\n$options$sep" as well as a new The only possible new feature along these lines would be to have a switch to change the way the long option keys are rendered in the help table, but I don't know if that's really worthwhile - there are an unbounded number of |
🤦 Thank you, I now remember reading about this style-insensitive nature of the switches.
Would have liked to have the help show only the Unix-style switches instead of the camelCase as they are more common, at least in my experience. Regarding:
I doubt if that's very common.. one would expect But I appreciate you taking time to write back, with that much detail. I will study the source code. |
It wouldn't be so hard to map just a lower-to-upper case transition to a "-lower" in the help table, but that is also just one of many choices. It seems better to me to just remind/explain the flexibility (a choice which is admittedly quite rare). |
By the way, I just added a |
I tried adding a
Can you give an example of overriding Thanks. |
My comment above might be a part lie/expression of hope more than reality. The distributed Anyway, I'm sure that the user override aspect of this feature is at least incomplete. That relates to In the meanwhile, I am also happy to accept any PR updating the default snake -> kebab transformation, if you have one. I almost did a camelCase -> kebab one in there, but didn't get around to it as it's more involved logic than just underscore to dash. |
Even if you (or @pb-cdunn) have a set of rules for doing camel->kebab, I could try to code them up. The most naive rule of just lower->upper case transition ==> dash,lowercase would seem to break in cases with adjacent capitals like We could also just have type Action = enum
printDNA = "print-DNA", RNAwrite = "RNA-write" (I haven't quite tested the enum thing on the help printing/output side, but it definitely works on the parsing/input side.) Even so, it would be best to have the default automatic procedure work so well that people almost never have to think about the 3 distinct override paths. This camel->kebab (or camel->snake which we can trivially kebabify) also smells like the kind of problem others have probably run into over the decades. So, there may be some guidance/wisdom in terms of rules out on the Internet at large, at least for English. |
also relates to #28). Also make short={"whAteVer-SpelIng":..} work. Move containsParam, formalParamExpand, and formalParams back to cligen.nim since optionNormalize'ing makes them no longer general purpose. Tweak a few test programs to check work & update ref output.
Hello,
I am trying to use
cligen
to generate standard Unix-style long options like--foo-bar
instead of--fooBar
.As
cligen
infers the long form switch names from theproc
arguments, I cannot set the argument identifiers to something likegit-skip
orwait-skip
(as I would like to get the long form options as--git-skip
and--wait-skip
). Instead I need to doGitSkip
(ignore the capital G.. I did that just as a quick way to get-G
as the short form switch).Would it be possible to have a
cligen
configuration that auto-converts all camel/snake caseproc
args to kebab-case for the long-form switches?Here is what the help of my little script looks like:
Here is the full code.
The text was updated successfully, but these errors were encountered: