*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 9bf58f77 authored by Moser, Maximilian's avatar Moser, Maximilian
Browse files

Add `vrc` shell command to access the auto API from the shell

* for now, only `download()` is supported
parent 619d4a29
Branches
No related tags found
1 merge request!7v0.3.0
...@@ -7,6 +7,9 @@ license = "MIT" ...@@ -7,6 +7,9 @@ license = "MIT"
readme = "README.md" readme = "README.md"
repository = "https://gitlab.tuwien.ac.at/fairdata/vre-repository-connector" repository = "https://gitlab.tuwien.ac.at/fairdata/vre-repository-connector"
[tool.poetry.scripts]
vrc = "vre_repository_connector.cli:connector"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = ">=3.11" python = ">=3.11"
inveniordm-py = "^0.1.0" inveniordm-py = "^0.1.0"
......
# -*- coding: utf-8 -*-
#
# Copyright (C) 2024 TU Wien.
#
"""CLI commands for the VRE Repository Connector."""
import sys
import click
from .auto import download, suggest_repository
@click.group()
def connector():
"""CLI commands for the VRE Repository Connector."""
@connector.command("download")
@click.argument("url")
@click.option(
"--all",
"-a",
default=False,
is_flag=True,
help="Download all files (overrides interactivity)",
)
@click.option(
"--select-interactive/--non-interactive",
"-i/-I",
default=True,
help="Select the files to download interactively",
)
def download_files(url: str, all: bool, select_interactive: bool):
"""Download the files from the given URL."""
if suggest_repository(url) is None:
click.secho("Couldn't deduce a repository from the URL!", fg="red", err=True)
files = download(url, all=all, interactive=select_interactive)
if files is None:
click.secho("No files downloaded.", fg="red", err=True)
sys.exit(1)
if isinstance(files, str):
files = [files]
for f in files:
click.echo(f)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment