DanCardin / cappa

Declarative CLI argument parser
Apache License 2.0
135 stars 8 forks source link

docs: Document index of "Subcommands" group #163

Closed pawamoy closed 3 weeks ago

pawamoy commented 4 weeks ago

I had to play a bit with different values to find out that the "Subcommands" group has index 3 or 4. I'm still not sure because I don't know what happens if two groups have the same index :slightly_smiling_face: EDIT: ah, seems to be 3: https://cappa.readthedocs.io/en/latest/api.html#cappa.Subcommand.group

Is there a way to change the "Subcommands" group index by the way? 3 or 4 seems too low, if I add this many groups some will end up after the "Subcommands" one :thinking:

pawamoy commented 4 weeks ago

Oh and https://cappa.readthedocs.io/en/latest/arg.html#arg-group-groups-and-mutual-exclusion mentions this Group object but it doesn't cross-ref to its documentation, and I can't find it in the API reference.

DanCardin commented 4 weeks ago

cappa.Subcommands[Foo] is just Annotated[Foo, cappa.Subcommand()], to which you can supply group=... whatever you want.

I would expect groups to show up in the order they're encountered/defined, assuming the same index.

but yes, perhaps subcommands/help should be a large number, or or some extra Group attribute that indicates they should always go after normal group items.

pawamoy commented 4 weeks ago

Thanks! Annotated[Foo, cappa.Subcommand(group=(100, "Subcommands"))] is working well! I might even prefer this syntax to cappa.Subcommands: less nesting, and makes https://github.com/DanCardin/cappa/discussions/164 a non-issue!