cliche icon indicating copy to clipboard operation
cliche copied to clipboard

Grouping

Open kootenpv opened this issue 3 years ago • 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.

kootenpv avatar Jan 18 '22 12:01 kootenpv

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.

kootenpv avatar Jan 18 '22 12:01 kootenpv

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

kootenpv avatar Jan 25 '22 01:01 kootenpv

Currently it is possible to use both syntaxes:

@cli

and

@cli("group_name")

kootenpv avatar Jan 25 '22 01:01 kootenpv