Closed pb-cdunn closed 5 years ago
Even simpler:
import cligen
import os
proc main*(): int =
echo "pb main"
if isMainModule:
dispatch(main)
Same error!
if isMainModule:
must be
when isMainModule:
Of course!
Btw, this is super cool:
% ./pb data -h
Unknown subcommand "data". Maybe you meant one of:
dataset
Great idea!
Glad you figured out your mistake.
On the topic of your final comment, did you read my message about maybe doing Mercurial/gdb/gnuplot-like acceptance of the shortest uniquely identifying prefix command/option/enum value? In this example, the command would have just executed if you had no other commands prefixed by "data".
That idea has a strong flavor of Do What I Mean / I don't care how verbose the CLI author made things, I'm going to use the short way. Indeed, it creates almost a middle-step from "short options" to "longest options" with this intermediate shortest matching prefix "long-ish" option/string matching.
It doesn't really obsolete the suggestion framework, though it might make more sense to expand that to understand the difference between "does not match a unique prefix" vs "no string starts with that prefix". and, of course, like the long options, subcommands, and enums it would apply to all three cases. It probably helps more in multi-command/enum settings.
It's kind of a rare/obscure feature, though in some ways multi-commands are all a bit more rare/idiosyncratic. Personally, I like it a lot. One of the frustrations I have moving between mercurial and git repos is git requiring all this specificity..I miss just "st" instead of the longer "status". But I get that people (especially detail-oriented programmers) also want specificity. So, if I ever do add this it will be easy to turn off or not on by default.
On the topic of your final comment, did you read my message about maybe doing Mercurial/gdb/gnuplot-like acceptance of the shortest uniquely identifying prefix command/option/enum value? In this example, the command would have just executed if you had no other commands prefixed by "data".
I like the current way better. I'm not a fan of automating everything, but as a user I love to be informed of what I probably should have done. It saves time, and it feels empowering.
Ok. One vote for "off by default" if I ever add that. Fair enough. :-)
Actually, accepting truncated sub-commands would be very useful, similar to truncated options.
Hmm. What did you think I meant by shortest uniquely identifying prefix if not truncation? I think that means the same thing..Just one has more a "set of choices" perspective while the other is maybe more user-centered.
Oh, then yes. Up-vote!
Ok. This one's a bit more work, though. Normalizing a string for matching purposes requires the whole set of choices, not just the identifier itself..normalizing is sort of the "maximum truncation that preserves uniqueness". So, internal stuff has to change to support it/make those choice sets available at matching time. Not sure when/if I'll get around to it, but it's obv. quite off topic for this issue. :-) You just mentioned liking the suggestion framework and this is a related idea.
Oddly, this does not happen for another package, using the same
$NIMBLE_DIR
. Here is my simple program: