diff --git a/requirements-swh.txt b/requirements-swh.txt --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -0,0 +1 @@ +swh.core >= 0.0.60 diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -73,6 +73,8 @@ entry_points=''' [console_scripts] swh-identify=swh.model.cli:identify + [swh.cli.subcommands] + identify=swh.model.cli:identify ''', classifiers=[ "Programming Language :: Python :: 3", diff --git a/swh/model/cli.py b/swh/model/cli.py --- a/swh/model/cli.py +++ b/swh/model/cli.py @@ -9,6 +9,8 @@ from functools import partial +from swh.core.cli import CONTEXT_SETTINGS + from swh.model import identifiers as pids from swh.model.exceptions import ValidationError from swh.model.from_disk import Content, Directory @@ -62,7 +64,7 @@ return (obj, pid) -@click.command() +@click.command(context_settings=CONTEXT_SETTINGS) @click.option('--dereference/--no-dereference', 'follow_symlinks', default=True, help='follow (or not) symlinks for OBJECTS passed as arguments ' @@ -74,7 +76,7 @@ help='type of object to identify (default: auto)') @click.option('--verify', '-v', metavar='PID', type=PidParamType(), help='reference identifier to be compared with computed one') -@click.argument('objects', nargs=-1, +@click.argument('objects', nargs=-1, required=True, type=click.Path(exists=True, readable=True, allow_dash=True, path_type=bytes)) def identify(obj_type, verify, show_filename, follow_symlinks, objects): @@ -90,13 +92,13 @@ Examples: \b - $ swh-identify fork.c kmod.c sched/deadline.c + $ swh identify fork.c kmod.c sched/deadline.c swh:1:cnt:2e391c754ae730bd2d8520c2ab497c403220c6e3 fork.c swh:1:cnt:0277d1216f80ae1adeed84a686ed34c9b2931fc2 kmod.c swh:1:cnt:57b939c81bce5d06fa587df8915f05affbe22b82 sched/deadline.c \b - $ swh-identify --no-filename /usr/src/linux/kernel/ + $ swh identify --no-filename /usr/src/linux/kernel/ swh:1:dir:f9f858a48d663b3809c9e2f336412717496202ab """