Gitlab Community Edition Instance

Skip to content

Alternative command registration mechanism

rforkel requested to merge command-registration into master

In this setup commands are registered by simply subclassing pycdstar3.cli.commands.base.Command, i.e. a new command can be added by only dropping a module with the implementation into pycdstar3/cli/commands, thus obeying the principle of locality.

Another advantage of this approach is that the Command base class can implement generic functionality, like calling subparsers.add_parser and setting the main property.

A slight disadvantage is the somewhat hacky way to import all modules in pycdstar3/cli/commands.

Right now, commands are registered under their class name, but some decorator magic could help in case a command name might clash with - say - a python keyword.

Merge request reports