I ditched `brew` for `nix` a while back and while the TUI could be more end-user-friendly (to the point that I wrote a wrapper called "ixnay" just so I could do "ixnay install <packagename>" as easily as with brew, https://github.com/pmarreck/ixnay), the overall guarantees make it worth it.
(the script itself is of no use to you since it only talks to a piece of hardware)
The command dispatcher case statement and all the embedded help is in do_cmd() at 2857, and the help reader is help() at 425
I like their explicit #args vs #help
One jank in mine is I have a verbosity level setting which affects most messages, and help() uses it to filter some of the help. Normal verbosity shows only the normal help for the normal commands. If verbosity is set higher, then help() shows more commands.
The way that's implimented in help() is extra comments that change the behavior of help() as it's scanning the file from top to bottom.
When it hits a '#v 2' it starts only displaying the help if the user has currently set verbosity>=2 until further notice. Later down the file it hits a '#v 1' and starts displaying help again...
It works but it feels kind of 70's or assembly.
#v 1
#h normal help for mortals
#h ...
#v 2
#h don't confuse the simple folk with this dangerous powerful stuff...
#h ...
#v 1
#h a few more normal commands
#h ...
#v 0
#h display this even the user has set verbosity to 0 to request silence
#h ...
I mean, this is basically all of Bash lol. A very clever idea that has endured since the 70's but also shows it... And yet we get obsessed with "writing perfect Bash" still.
The amazing thing is that there are also old "functional shells" like es-shell https://wryun.github.io/es-shell/ (he still works on this and it is indeed very interesting!)
I wish I had known about ixnay earlier! I also got annoyed of the user experience, to the point where I also wrote my own tool, hdn: https://github.com/seasonedfish/hdn
I just noticed there's a bug with uninstalling. Probably a parsing issue, they must have changed the output of nix for that (this isn't the first time that happened...)