Skip to content
Snippets Groups Projects
Commit f42442b5 authored by David Douard's avatar David Douard
Browse files

cli: replace the 'vault' cmd with cli group with a 'rpc-serve' subcmd

so that one should use:

  swh vault rpc-server

as in other swh packages.

The deprecated swh-vault command should still work as expected.
parent 194fb311
No related branches found
No related tags found
1 merge request!44cli: replace the 'vault' cmd with cli group with a 'rpc-serve' subcmd
swh.core[db,http] >= 0.0.60
swh.core[db,http] >= 0.0.61
swh.model >= 0.0.27
swh.objstorage >= 0.0.17
swh.scheduler >= 0.0.39
......
import logging
import click
import aiohttp
from swh.vault.api.server import make_app_from_configfile
from swh.core.cli import CONTEXT_SETTINGS, AliasedGroup
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@click.group(name='vault', context_settings=CONTEXT_SETTINGS,
cls=AliasedGroup)
@click.pass_context
def vault(ctx):
'''Software Heritage Vault tools.'''
pass
@click.command(name='vault', context_settings=CONTEXT_SETTINGS)
@vault.command(name='rpc-serve')
@click.option('--config-file', '-C', default=None,
type=click.Path(exists=True, dir_okay=False,),
help="Configuration file.")
......@@ -21,11 +25,13 @@ CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@click.option('--debug/--no-debug', default=True,
help="Indicates if the server should run in debug mode")
@click.pass_context
def cli(ctx, config_file, no_stdout, host, port, debug):
def serve(ctx, config_file, no_stdout, host, port, debug):
"""Software Heritage Vault API server
"""
import aiohttp
from swh.scheduler.celery_backend.config import setup_log_handler
from swh.vault.api.server import make_app_from_configfile
ctx.ensure_object(dict)
setup_log_handler(
......@@ -42,9 +48,12 @@ def cli(ctx, config_file, no_stdout, host, port, debug):
aiohttp.web.run_app(app, host=host, port=int(port))
vault.add_alias(serve, 'serve')
def main():
logging.basicConfig()
return cli(auto_envvar_prefix='SWH_VAULT')
return serve(auto_envvar_prefix='SWH_VAULT')
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment