kootenpv/cliche

Grouping

Opened this issue · 3 comments

  1. auto class-based groups (only if more than 1 fn in a class)
  2. auto module-based groups (only if more than 1 fn in a module)
  3. based on decorator (let user decide), e.g. @cli(group="mygroup")

I really don't like 3 because I prefer the decorator to have no options (if I'd ever add options, it would mostly likely be at the install stage). With 3 there is also no chance to speed up load times.

I really think 1 and 2 should be implemented.

Regarding 2):

So for example, imagine a cli called tool

We start implementing a function sell in a module called products.py.

Then we can call it like:

tool sell

Now when we add buy, I think what should happen is that it becomes:

tool products sell
tool products buy

However, as long as there is no name clash with anything else, it could accept

tool sell

and emit a yellow warning on stderr that tool sell should be updated to tool products sell.

tool products --help would be very fast as it wouldn't have to parse all files in large projects

I think this will work very nicely.

Encountered a few examples that made module-based auto-generation kinda awkward.

Eventually ended up wanting to stuff a lot of a single module, which got crowded.
So then would create a wrapper function which was more sinful.

implemented 3) instead

Currently it is possible to use both syntaxes:

@cli

and

@cli("group_name")