-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
parseopt: high level helper #12425
Comments
/cc @c-blake as he might be one of the best experts in this field. May be "something in-between" Nim stdlib and his cligen package can be ported to Nim stdlib? (I would be happy if the whole cligen is ported to Nim stdlib :D) |
I think I'd be fine with inclusion in the stdlib instead of a Nimble package, but I think this runs counter to the zeitgeist of trimming the stdlib. I had originally hoped to at least get |
I'm aware of cligen. The main reason to have a (simpler) subset of its features in the stdlib is that CLI and config file parsing is a very common requirement for most developers and it hardly warrants adding a dependency on an external library. |
Why not start this as a Nimble package? I 100% agree that we need something more friendly than parseopt, but I don't think whatever is developed should be included immediately in the stdlib without at least some testing as a Nimble package. |
I may be biased, but I feel like |
I'm against the idea of a parseopt3 when cligen is successful and popular. I'd rather see it added to the stdlib. It has proved itself as a nimble package. I understand there's been discussions around removing older cruft but I don't see why we cannot continue to add mature packages into the stdlib. I've not seen any in the last two years and it honestly makes no sense. |
Minor point of clarification - when I said |
We need an RFC if and how to grow Nim's stdlib. |
I would prefer to see in the
|
I think you may misunderstand Also, the most minimal usage of |
@c-blake Probably, you are right, but there are some concerns related to the
|
Readability, convenience, preferences are subjective. Mandatory vs. optional is handled by the The only main restriction you mention which is true is exclusivity/groups. Note, this is also beyond the syntax of usual procedure calls. I would say that "beyondness" calls its value into question. I'm open to possibly supporting it, but again such feature requests belong over on my git repo not here. You can always write a custom wrapper around some existing API that does exclusivity checks (which Nim importing/calling users might also appreciate!), but grouping is more syntax/parseopt behavior.
You've mentioned doc strings a couple times when I think you mean doc comments. This suggests you are new to Nim coming from Python. Welcome! I kind of suspect what you may really be after is a kind of "Python -> Nim porting library/system" - a full suite of many modules and procs whose names, structure, and behavior mimic as closely as possible the Python stdlib/stdecosystem..This would let people change their mental models of various task decompositions as little as possible and port code/scripts as quickly as possible. Maybe even with a This thread is roughly of the form "stdlib |
…s via nim-lang/Nim#12425 Usage is the CL author saying `help={"param": "SUPPRESS"}` with the special string being re-definable via, e.g., `clCfg.hTabSuppress = "**HIDDEN**"`. Ammend test prog to try it out & update reference output for line numbers.
Well, I went ahead and added that requested feature of hidden/suppressed help rows over in c-blake/cligen@0cd1c5e . I agree that is common enough in other CLIs to support. One more feature to explain, of course. |
People are still complaining about the lack of better parseopt features in the stdlib: https://news.ycombinator.com/item?id=22401953 |
I think the setup people were leaning toward is a distribution where certain popular packages might be "bundled" with Nim. For example, If it matters, I'm planning on stamping |
This issue thread should be cross-linked to the RFC discussion: nim-lang/RFCs#173 |
Current parseopt is a bit cumbersome, but it's workable and more or less idiomatic. However, I think something that behaves in a more common (POSIX-y) way would be a nice addition to the stdlib. Specifically:
Were there any efforts for inclusion of cligen/parseopt3 into the stdlib? I see it being suggested here and there but no sign of concrete actions to facilitate the inclusion. |
@genotrance's above two years has now become almost 6. AFAIK, fusion is long abandoned, nothing ever moved from there or stew to stdlib, and Araq still wants the stdlib on a slimming trajectory so that he need not oversee things he doesn't care much about, with plans only to shrink not grow (including his own recent Is it a good plan? Dunno. I've said it before, but features/batteries included sell software and trusted lieutenants for subsystems is usually how people scale software, not delegation to a la carte package management or certain individuals managing every detail, BUT trust sure is tricky. As far as I know, not a single library package for Nim nor any "meta-installer" has made it into any Linux distro ecosystems as .rpm/.deb/.ebuild/.xps/whatever. Meanwhile, the Nim compiler/stdlib itself is commonly packaged and has been for 10+ years. So, to install anything written in Nim using beyond the stdlib, brand new users must learn nimble/atlas/nimph/nimp/NBS/whatever OR some bespoke installer for the app itself (and more significantly encounter installer failure modes) unless that installer" is just "nim c foo". This subtlely pressures program writers to be dependency allergic / make more monolithic packages with shallow dep trees with manageable manual interventions (maybe not the end of the world, but also maybe not ideal and I have personally gotten pushback). So, I think it's only a better plan for Nim adoption than growing the stdlib IF you have a rock solid build system/installer/pkg mgmt story which still feels very.. debatable? in NimLand. NimScript is itself pretty capable for package-custom installer logic. AFAICT, the man page installation I recently did for To end on a more concrete note which may be more helpful, I am unaware of anyone besides @ZoomRmc who just uses that directly, though, and the request opening this was asking for almost all cligen (but with an |
I'm still in favor of "batteries included" but at this point we cannot really provide it and the final nails in the coffin for me is CI and github integration in general. It's just so nice if you start with a new tiny project and it has a CI that gives you feedback in the minutes. Also nice if the github issues are all on the same topic and the issue numbers are not 5 digits long. |
Summary
parseopt provides low-level procs and requires for+case to extract parsed values.
Nim could provide a more practical helper.
Features
<name>.cfg
in known locations, read it and populate the configuration object. CLI options override the contents of the filesfoo delete cache; foo help delete
-o foo
The text was updated successfully, but these errors were encountered: