Skip to content

Add a class-based way to define subcommands in submodules (#1064, #788)

Enrico Zini requested to merge refactor-cli-modular into devel

Since it was decided to start using a 'object verb' syntax for the debusine client, before adding a new command for #788 I'm trying to set up that possibility.

This MR is filed early for design review: if you like the way it's going, I'll port the rest of the command line argument implementations and fix their tests.

There is code duplication between debusine.client.cli.Cli and debusine.client.commands.base.DebusineCommand, and the idea is that it all gets removed from Cli once all commands are ported.

This MR introduces:

  • The ability to define groups of commands in their own separate modules and have them automatically be picked up
  • The ability to group commands in sub-subparsers
  • The ability to have the same command implementation show in multiple ways (in particular, as a "object verb" and as the legacy compatibility version)
  • The ability for commands to run with different set of prerequisites (compare work-request ones with setup, which doesn't need a debusine client)
  • Significant more DRY-ness

argcomplete seems to understand sub-subparsers, according to the following command, but I don't have argcomplete set up in my system to test it fully:

_ARGCOMPLETE=1 _ARGCOMPLETE_STDOUT_FILENAME=/dev/stdout COMP_LINE="debusine work-request " COMP_POINT=22 python3 -m debusine.client

Let me know if I can go ahead down this path

Edited by Colin Watson

Merge request reports

Loading