Skip to content
Snippets Groups Projects
Commit 2b688f8f authored by Thibault Allançon's avatar Thibault Allançon
Browse files

cli: use SWHIDParamType from swh.model.cli

See D4139.
parent f7194e5a
No related branches found
No related tags found
No related merge requests found
# Add here internal Software Heritage dependencies, one per line.
swh.core
swh.model
swh.model>=0.7.0
swh.web.client
......@@ -16,7 +16,7 @@ from daemon import DaemonContext
# from swh.core import config
from swh.core.cli import CONTEXT_SETTINGS
from swh.model.identifiers import SWHID
from swh.model.cli import SWHIDParamType
# All generic config code should reside in swh.core.config
DEFAULT_CONFIG_PATH = os.environ.get(
......@@ -44,24 +44,6 @@ DEFAULT_CONFIG: Dict[str, Tuple[str, Any]] = {
}
class SWHIDParamType(click.ParamType):
"""Click argument that accepts SWHID and return them as
:class:`swh.model.identifiers.SWHID` instances
"""
name = "SWHID"
def convert(self, value, param, ctx) -> SWHID:
from swh.model.exceptions import ValidationError
from swh.model.identifiers import parse_swhid
try:
return parse_swhid(value)
except ValidationError:
self.fail(f'"{value}" is not a valid SWHID', param, ctx)
@click.group(name="fuse", context_settings=CONTEXT_SETTINGS)
# XXX conffile logic temporarily commented out due to:
# XXX https://forge.softwareheritage.org/T2632
......
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