Command-line interface#
Shell Completion#
You may activate the command line completion mechanism for your shell. The swh tool is using the click package, so activating command completion is a simple matter of:
Add this to your .bashrc
eval "$(_SWH_COMPLETE=bash_source swh)"
Add this to your .zshrc
eval "$(_SWH_COMPLETE=zsh_source swh)"
See click documentation for more details and options.
Database initialization utilities#
swh db init#
Initialize a database for the Software Heritage <module>.
As for the ‘init-admin’ command, the database connection string can come
either from the –dbname option or the configuration file (see option
--config-file
in swh db --help
) in the section named after the
MODULE argument in most cases.
When retrieved from within the configuration, the db connection string can be looked after from any location in the configuration using the <module-or-config-path> option. For example:
$ cat conf.yml
storage:
cls: pipeline
steps:
- cls: masking
masking_db: postgresql:///?service=swh-masking-proxy
- cls: buffer
- cls: postgresql
db: postgresql://user:passwd@pghost:5433/swh-storage
objstorage:
cls: memory
$ swh db -C conf.yml init storage # or
$ SWH_CONFIG_FILENAME=conf.yml swh db init storage # or
$ swh db init --dbname postgresql://user:passwd@pghost:5433/swh-storage storage
$ # to initialize the "main" storage db (expected to be the last element
$ # of a pipeline config),
$ # or to initialize the masking_db:
$ swh db -C conf.yml init -p storage.steps.0
Usage of –module-config-key is now deprecated in favor of “full-path” module/config entry.
swh db init [OPTIONS] MODULE-OR-CONFIG-PATH
Options
- -d, --dbname, --db-name <dbname>#
Database name or connection URI.
- --flavor <flavor>#
Database flavor.
- --module-config-key <module_config_key>#
Module config key to lookup.
- -a, --all#
initialize all db found in the config file for the swh ‘module’
- -p, --module-is-path#
If set, inpterpret the given ‘module’ as a config ‘json path’ within the config file
Arguments
- MODULE-OR-CONFIG-PATH#
Required argument
swh db-init#
Initialize a database for the Software Heritage <module>.
As for the ‘init-admin’ command, the database connection string can come
either from the –dbname option or the configuration file (see option
--config-file
in swh db --help
) in the section named after the
MODULE argument in most cases.
When retrieved from within the configuration, the db connection string can be looked after from any location in the configuration using the <module-or-config-path> option. For example:
$ cat conf.yml
storage:
cls: pipeline
steps:
- cls: masking
masking_db: postgresql:///?service=swh-masking-proxy
- cls: buffer
- cls: postgresql
db: postgresql://user:passwd@pghost:5433/swh-storage
objstorage:
cls: memory
$ swh db -C conf.yml init storage # or
$ SWH_CONFIG_FILENAME=conf.yml swh db init storage # or
$ swh db init --dbname postgresql://user:passwd@pghost:5433/swh-storage storage
$ # to initialize the "main" storage db (expected to be the last element
$ # of a pipeline config),
$ # or to initialize the masking_db:
$ swh db -C conf.yml init -p storage.steps.0
Usage of –module-config-key is now deprecated in favor of “full-path” module/config entry.
swh db-init [OPTIONS] MODULE-OR-CONFIG-PATH
Options
- -d, --dbname, --db-name <dbname>#
Database name or connection URI.
- --flavor <flavor>#
Database flavor.
- --module-config-key <module_config_key>#
Module config key to lookup.
- -a, --all#
initialize all db found in the config file for the swh ‘module’
- -p, --module-is-path#
If set, inpterpret the given ‘module’ as a config ‘json path’ within the config file
Arguments
- MODULE-OR-CONFIG-PATH#
Required argument