Hacker GitHub

← All repos

c-blake/cligen

View on GitHub ↗ ★ 584 Nim

Nim library to infer/generate command-line-interfaces / option / argument parsing; Docs at

57 mentions on Hacker News by 8 people: 1 story, 56 comments · first 2018-08-17 · latest 2026-10-13

Mentions per year 57 mentions · busiest year 2023 (12)
20082026
  1. …has nice compile-time introspection and very low effort macros to allow packaging near zero-code APIs like github.com/c-blake/cligen. Also, something like 5 out of 5 times I've investigated some Rust alternative to some Nim code, the Rust…
  2. One application of such a feature would be something like a "cligen.c3" (like the Nim https://github.com/c-blake/cligen or its /python/cg.py port or etc.). Mostly it just seems a more complete signature extraction, though. Any other kind…
    comment by cb321 · 2026-01-03 · in The C3 Programming Language
  3. …styles than Python, including a special iterator syntax whose "call" is a for-construct. [1] https://github.com/c-blake/cligen/blob/master/cligen/print.n...
    comment by cb321 · 2025-10-31 · in Nim 2.2.6
  4. Even better, in Nim these little CLI tools could use https://github.com/c-blake/cligen and have had terminal colorized, auto-generated help for many years now with much less dev-effort than raw argparse. Start-up time of statically linked…
    comment by cb321 · 2025-10-10 · in Python 3.14 is here. How fast is it?
  5. …library authors and library users so that they specifically have to learn less. For example, https://github.com/c-blake/cligen makes it so that you don't really have to learn an "API" to roll a nice CLI on top of a procedure. You just need…
    comment by cb321 · 2025-08-18 · in Why Nim?
  6. …is a stab at an auto-generation framework from said data for the Nim CLI toolkit, cligen, over at: https://github.com/c-blake/cligen/blob/master/util/complgen.... but it only works for Zsh right now. Anyway, I don't think perfect should be…
  7. …said colorization if NO_COLOR[1] is set then you can prefix _gnu_generic with NO_COLOR=1 as in https://github.com/c-blake/cligen/wiki/Zsh-completion-for-cl... for the cligen Nim CLI toolkit. A similar thing in Bash is `complete -F _longopt…
  8. …subthread in one of the hundreds of closed issue threads got into a comparison of dups and jdupes ( https://github.com/c-blake/cligen/issues/99#issuecomment-485... ) where Jody shows up. I mean, in my test cases dups fared well, but on…
  9. …usable and, I bet @cb321 will confirm, in some cases are competitive with widely-used alternatives. https://github.com/c-blake/cligen/tree/master/examples
  10. …the value. Then you can say `cut -d:=` or `cut -d=:` if you wanted to use either one. This is what https://github.com/c-blake/cligen does (for Nim, not Go).
  11. Another example applying compile-time reflection is something like https://github.com/c-blake/cligen { but it helps if your host prog.lang has named parameters like Python's foo(a=1, b=2) }.
    comment by cb321 · 2025-01-07 · in Zig's comptime is bonkers good
  12. https://github.com/c-blake/cligen makes whipping up CLI utilities very easy in Nim with a pretty fancy CL-user experience (colorized, user-tunable --help, Zsh/bash completions, brief long options, spellcheck/autosuggest on typos, etc.). As…
  13. When making small Nim programs for the CLI, https://github.com/c-blake/cligen makes for a pretty simple API (just 1 line of code) that gets you nice CLI syntax, color auto-generated help messages, etc.
  14. …the 2 `var`s and change `print` -> `echo`. { EDIT: though if you love Py print(), there is always https://github.com/c-blake/cligen/blob/master/cligen/print.n... or some other roll-your-own idea. Then instead of py2/py3 print x,y vs…
  15. …it is not as full-featured as stdlib `string`, there is a zero-copy `cligen/mslice.MSlice` type ( https://github.com/c-blake/cligen/blob/master/cligen/mslice.... ) that does have basic features like splitting and number parsing. There are…
  16. There is also generating the whole thing from a function signature (e.g. https://github.com/c-blake/cligen ) since then CLauthors need not learn a new spec language, but then CLauthors must add back in helpful usage metadata/semantics and…
    comment by cb321 · 2024-01-12 · in CLI user experience case study
  17. cligen also allows End-CL-users to adjust colorization of --help output like https://github.com/c-blake/cligen/blob/master/screenshots/di... using something like https://github.com/c-blake/cligen/wiki/Dark-BG-Config-File Last I knew, the…
  18. …take a look at Nim: https://nim-lang.org . Nim has cligen library to generate and parse arguments: https://github.com/c-blake/cligen And to prove what Nim's capable of - here's a cool repo with 100+ cli apps cligen author wrote in Nim:…
  19. …54 environment variables. The program only does about 17 system calls total, though. Additionally, https://github.com/c-blake/cligen makes decent CLI tools a real breeze. If you like some of Go's qualities but the language seems too…
  20. …this article interesting and are curious about Nim then you would probably also be curious about https://github.com/c-blake/cligen That allows adding just 1-line to a module to add a pretty complete CLI and then a string per parameter to…
  21. …for C, even Windows has popen these days. There are also some tiny Nim popenr/popenw wrappers in https://github.com/c-blake/cligen/blob/master/cligen/osUt.ni... covering the Windows case. Depending upon how balanced work is on either side…
  22. …code to then generate related/translated ASTs to create nearly frictionless helper facilities like https://github.com/c-blake/cligen . You can do all of this without any real run-time speed sacrifices, depending upon the level of effort…
    comment by cb321 · 2023-08-12 · in The Bipolar Lisp Programmer (2007)
  23. …bu page. Regarding cligen, right from the start clap wins on producing idiomatic output. Compare: https://github.com/c-blake/cligen#cligen-a-native-api-inferr... Usage: fun [optional-params] [args: string...] An API call doc comment…
  24. …and I realize your post was more about "why Rust?" rather than "why not Nim?", but that said the https://github.com/c-blake/cligen Nim CLI framework seems much lower effort / ceremony than even Rust's `argh` and is just about as old as…
  25. …about adoption, IMO. "Performant" has many dimensions. That said, I just tested the Nim https://github.com/c-blake/cligen vs clap: cligen used 5X less object file space (with all size optimization tweaks enabled in both), 20% less run-time…
    comment by cb321 · 2023-03-30 · in Zig and Rust
  26. …in files or use a SHA256 of a content-based first slice. ( There are edit distance algos in Nim in https://github.com/c-blake/cligen/blob/master/cligen/textUt.... as well as in https://github.com/c-blake/suggest ). Or, you could do a…
    comment by cb321 · 2023-03-07 · in Self-Host All the Things?
  27. …and probably N others. Personally, I prefer Nim to Python which has https://github.com/c-blake/cligen . As mentioned in https://github.com/c-blake/cligen/blob/master/MOTIVATION.md , but not in the borretti article, the overhea
    comment by cb321 · 2023-02-08 · in Shells are two things
  28. …is perfect, there is much to recommend it. By now I've written over 150 command-line tools with https://github.com/c-blake/cligen . A few are at https://github.com/c-blake/bu or https://github.com/c-blake/nio { screw 1970s COBOL-esque SQL…
    comment by cb321 · 2023-01-03 · in Offensive Nim
  29. …macro system can (some of the time) get you similar powers to Python's dynamic reflection. E.g., https://github.com/c-blake/cligen instead of `autocommand` or `click` or `argh` or you name the automatic CLI generator, only with full C-like…
    comment by cb321 · 2022-12-30 · in Why I'm still using Python
  30. …to such nice conveniences and are willing to learn Nim, I might then recommend something more like https://github.com/c-blake/cligen
  31. …found this slower-than-C to be the case. You may need to use something like `iterator getDelims` in https://github.com/c-blake/cligen/blob/master/cligen/osUt.ni... to manage memory with fewer copies/less alloc "more like C", though or…
    comment by cb321 · 2022-11-11 · in A cost model for Nim
  32. …that just receive a parsed AST. That can be used to "re-parse" or "re-compile" external code as in https://github.com/c-blake/cligen . So, trade-offs like in all of life. There is even a book called The Paradox Of Choice [1]. I think there…
    comment by cb321 · 2022-11-11 · in A cost model for Nim
  33. Re CLIs in Nim..Most find https://github.com/c-blake/cligen easy to use.
    comment by cb321 · 2022-10-26 · in Python 3.11 is faster than 3.8
  34. https://github.com/c-blake/cligen can make the CLI integration part pretty frictionless.
  35. …ps (Linux-only right now). It has a more canonical CLI since it is based upon the Nim CLI generator https://github.com/c-blake/cligen . It also uses cligen's subcommand feature (display, find, scrollsys) and so it can replace pgrep, pkill,…
  36. …Nim is suitable or teaching people introductory programming, though. [1] https://nim-lang.org/ [2] https://github.com/c-blake/cligen/blob/master/cligen/dents.n... [3] https://app.element.io/#/room/#nim-science:envs.net [4]…
    comment by cb321 · 2022-03-18 · in Python 3 Types in the Wild
  37. rp looks like a very interesting and clever approach. I'll have to take a closer look. Is https://github.com/c-blake/cligen/blob/master/examples/rp.ni... the extent of rp's documentation?
  38. …(EDIT: Awk is fairly well established, of course.) [1] https://forum.nim-lang.org/ [2] https://github.com/c-blake/cligen/blob/master/examples/rp.ni... [3] https://repo.or.cz/w/tinycc.git
  39. …"spec" language (the PL itself) and with less work. There are a few Python packages for this and https://github.com/c-blake/cligen (which lets you add a CLI to an existing API with just one line of code). This is theoretically even…
    comment by cb321 · 2021-12-31 · in Docopt
  40. …(Min time of 10 runs with the git repo housed by /dev/shm on Linux 5.15.) The "simple" code is in https://github.com/c-blake/cligen/blob/master/cligen/dents.n... (just `dents find` does not require the special kernel batch system call…
  41. This is roughly how https://github.com/c-blake/cligen/blob/master/examples/dups.... can work. There is little question that changing the scale of the problem very much lessons performance sensitivity to the hash.
    comment by cb321 · 2021-10-29 · in Meow Hash (2018)
  42. …at the problem) ever so slightly another answer exists in this space and is quite easy. :-) [1] https://github.com/c-blake/cligen/blob/master/examples/rp.ni...
  43. …to recap. Weave [4] would be a good place to start reading, though, or searching the Nim Forum. [1] https://github.com/c-blake/cligen/blob/master/cligen/procpool.nim [2] https://github.com/c-blake/cligen/blob/master/examples/grl.nim [3]…
    comment by cb321 · 2021-05-15 · in Nim 2.0 thoughts
  44. …And if you like colors, hldiff [3] is not a terrible example. [1] https://nim-lang.org/ [2] https://github.com/c-blake/cligen [3] https://github.com/c-blake/hldiff
  45. …types like macros, templates, etc., even the ones named like an operator such as `<`). [1] https://github.com/c-blake/cligen
    comment by cb321 · 2021-03-12 · in Patten Matching in Nim
  46. …bugs/things to workaround (as with any language), but Nim has been pretty usable for years. [1] https://github.com/c-blake/cligen
    comment by cb321 · 2021-02-22 · in Go is not an easy language
  47. …or so with Nim than you would with Rust. Nim really seems to "scale up gracefully" for most. [1] https://github.com/c-blake/cligen [2] https://news.ycombinator.com/item?id=25596285
    comment by cb321 · 2020-12-31 · in Nim in 2020: A Short Recap
  48. …That is an alternate, perhaps more keystroke-heavy solution to the problem bothering @simias. [1] https://github.com/c-blake/cligen/blob/master/cligen/macUt.n...
    comment by cb321 · 2020-12-23 · in Nim Apocrypha, Vol. I
  49. …your own impl. I did an (incomplete) Python multiprocessing like dealio in like 100 lines of code ( https://github.com/c-blake/cligen/blob/master/cligen/procpoo... ) just to make my `only.nim` run faster because libmagic/file are so CPU…
    comment by cb321 · 2020-10-16 · in Nim 1.4
  50. …you want to give that script a nice, traditional CLI then you can do so with very low effort using https://github.com/c-blake/cligen Should you want "script like" edit-test development cycle ergonomics you can use the TinyCC/tcc backend…
    comment by cb321 · 2020-10-16 · in Nim 1.4