Changeset View
Changeset View
Standalone View
Standalone View
swh/scanner/cli.py
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
@scanner.command(name="scan") | @scanner.command(name="scan") | ||||
@click.argument("root_path", required=True, type=click.Path(exists=True)) | @click.argument("root_path", required=True, type=click.Path(exists=True)) | ||||
@click.option( | @click.option( | ||||
"-u", | "-u", | ||||
"--api-url", | "--api-url", | ||||
default="https://archive.softwareheritage.org/api/1", | default="https://archive.softwareheritage.org/api/1", | ||||
metavar="API_URL", | metavar="API_URL", | ||||
show_default=True, | show_default=True, | ||||
help="url for the api request", | help="URL for the api request", | ||||
) | ) | ||||
@click.option( | @click.option( | ||||
"--exclude", | "--exclude", | ||||
"-x", | "-x", | ||||
"patterns", | "patterns", | ||||
metavar="PATTERN", | metavar="PATTERN", | ||||
multiple=True, | multiple=True, | ||||
help="recursively exclude a specific pattern", | help="Exclude directories using glob patterns \ | ||||
(e.g., '*.git' to exclude all .git directories)", | |||||
zack: Just the other day I was trying to use this, and couldn't.
This help string needs a… | |||||
Done Inline ActionsI think we should also mention that the patterns are translated into regex objects by fnmatch that uses shell-style wildcards. DanSeraf: I think we should also mention that the patterns are translated into regex objects by `fnmatch`… | |||||
) | ) | ||||
@click.option( | @click.option( | ||||
"-f", | "-f", | ||||
"--format", | "--format", | ||||
type=click.Choice(["text", "json", "ndjson", "sunburst"], case_sensitive=False), | |||||
default="text", | default="text", | ||||
help="select the output format", | show_default=True, | ||||
type=click.Choice(["text", "json", "ndjson", "sunburst"], case_sensitive=False), | |||||
help="The output format", | |||||
) | ) | ||||
@click.option( | @click.option( | ||||
"-i", "--interactive", is_flag=True, help="show the result in a dashboard" | "-i", "--interactive", is_flag=True, help="Show the result in a dashboard" | ||||
) | ) | ||||
@click.pass_context | @click.pass_context | ||||
def scan(ctx, root_path, api_url, patterns, format, interactive): | def scan(ctx, root_path, api_url, patterns, format, interactive): | ||||
"""Scan a source code project to discover files and directories already | """Scan a source code project to discover files and directories already | ||||
present in the archive""" | present in the archive""" | ||||
import asyncio | import asyncio | ||||
from .scanner import run | from .scanner import run | ||||
from .model import Tree | from .model import Tree | ||||
Show All 25 Lines |
Just the other day I was trying to use this, and couldn't.
This help string needs a description of pattern semantics and/or an example of a concrete pattern to help users.
Also, I think there is not default exclusion pattern, but if there is it should be mentioned here.
(And I also think it would be a good idea to exclude stuff like ".git" by default, but that is material for a separate diff.)