Command-line interface#

Shared command-line interface#

swh#

Command line interface for Software Heritage.

swh [OPTIONS] COMMAND [ARGS]...

Options

-l, --log-level <log_levels>#

Log level (defaults to INFO). Can override the log level for a specific module, by using the specific.module:LOGLEVEL syntax (e.g. --log-level swh.core:DEBUG will enable DEBUG logging for swh.core).

--log-config <log_config>#

Python yaml logging configuration file.

--sentry-dsn <sentry_dsn>#

DSN of the Sentry instance to report to

Environment variables

SWH_LOG_LEVEL

Provide a default for --log-level

Commands

alter

Archive alteration tools.

auth

Software Heritage Authentication tools.

backend

Software Heritage backend generic tools.

counters

Software Heritage Counters tools.

dataset

Dataset Tools.

db

Software Heritage database generic tools.

deposit

Deposit main command

fs

Software Heritage virtual file system

graph

Software Heritage graph tools.

identify

Compute the Software Heritage persistent…

indexer

Software Heritage Indexer tools.

lister

Software Heritage Lister tools.

loader

Loader cli tools

metadata-loader

Software Heritage Metadata Loader.

nar

Compute NAR hashes on a directory.

objstorage

Software Heritage Objstorage tools.

provenance

Software Heritage Provenance tools.

scanner

Software Heritage Scanner tools

scheduler

Software Heritage Scheduler tools.

scrubber

main command group of the datastore scrubber

search

Software Heritage Search tools.

storage

Software Heritage Storage tools.

vault

Software Heritage Vault tools.

web

Software Heritage web client

webhooks

Software Heritage Webhooks management…

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