Page MenuHomeSoftware Heritage

cli: add a generic main 'swh' command and extract the db-init command

Authored by douardda on Apr 19 2019, 12:13 PM.



in a dedicated submodule. Ensure both:

swh db-init




Related to T1671.

Diff Detail

rDCORE Foundations and core functionalities
Lint Skipped
Unit Tests Skipped
Build Status
Buildable 5512
Build 7486: tox-on-jenkinsJenkins
Build 7485: arc lint + arc unit

Event Timeline

douardda created this revision.Apr 19 2019, 12:13 PM
olasd requested changes to this revision.Apr 19 2019, 4:16 PM
olasd added a subscriber: olasd.
olasd added inline comments.

Do we really need the dict here? If so, would you mind adding a comment as to how/where it's being used in addition to the noqa? (and if not, I guess we can just flip around the for loop)

This revision now requires changes to proceed.Apr 19 2019, 4:16 PM
douardda added inline comments.Apr 19 2019, 4:19 PM

we probably do not need to keep this dict, but we need to ensure packages are loaded. Let me check this.

olasd added a comment.Apr 19 2019, 4:22 PM

So, from what I understand, the subcommand name is set by the name of the function in the plugin, when the swh.command() decorator is called.

I think it would be less surprising, if the entry points were used to actually define which functions are to be decorated, and the subcommand name.

So your entry point definition could be


And you could make the main or swh command lazy-load and decorate the proper function at runtime.

Does that make sense?

swh.cli.subcommands would certainly be more explicit ?


Useless use of swh-? :)

douardda updated this revision to Diff 4645.Apr 19 2019, 4:24 PM

no need to keep the cli plugins in a dict

douardda updated this revision to Diff 4682.May 2 2019, 3:19 PM

Implement the entrypoint loading mechanism using functions instead of modules

as suggested by olasd. This does not implement any generic lazy loading
magic stuff for now.

olasd accepted this revision.May 6 2019, 12:29 PM
This revision is now accepted and ready to land.May 6 2019, 12:29 PM
douardda updated this revision to Diff 4699.May 6 2019, 3:22 PM

include forgotten patch: add log_level to 'swh' context obj

so subcommands can do specific stuff with current log level if needed.

See swh/core/cli/

This revision was landed with ongoing or failed builds.May 6 2019, 3:23 PM
This revision was automatically updated to reflect the committed changes.