Skip to content

Certificates

Catalog a project's .veriphy/certificates/: python -m veriphy.certificates list or show <name>.

main(argv=None)

List the project's certificate scripts, or show one, as list [--root DIR] or show <name> [--root DIR].

Parameters:

Name Type Description Default
argv Sequence[str] | None

The command-line arguments, sys.argv[1:] when None.

None

Raises:

Type Description
SystemExit

With status 1 when show finds no script of that name, and 2 on bad usage.

Source code in src/veriphy/certificates/_catalog.py
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
def main(argv: Sequence[str] | None = None) -> None:
    """List the project's certificate scripts, or show one, as `list [--root DIR]` or `show <name> [--root DIR]`.

    Args:
        argv: The command-line arguments, `sys.argv[1:]` when `None`.

    Raises:
        SystemExit: With status 1 when `show` finds no script of that name, and 2 on bad usage.
    """
    args = _parser().parse_args(list(sys.argv[1:] if argv is None else argv))
    root = find_workspace_root(args.root)
    directory, legacy = _scripts_dir(root)
    if legacy:
        _warn_legacy(root)
    if args.command == 'list':
        prefix = f'{LEGACY_DIR}/' if legacy else ''
        sys.stdout.write(''.join(f'{_describe(p, prefix + p.name)}\n' for p in _scripts(directory)))
        return
    found = _find(directory, args.name)
    if found is None:
        sys.stderr.write(f"no certificate script named '{args.name}' in {directory}/\n")
        raise SystemExit(NOT_FOUND)
    sys.stdout.write(found.read_text())