Skip to content

CLI API

The uripath console script and python -m uripath. Usage is described in the CLI guide. main is the one name to call; the commands are duho classes in the modules beside it (uripath.cli.read, write, rm, cp and sync), and everything they do goes through the library.

uripath.cli

The uripath command line, built on duho.

main is the entry point of the uripath console script and of python -m uripath. It needs the cli extra (pip install "pathapi-uri[cli]"); importing this package does not, so a bare install gets one line naming the extra in place of an ImportError. The root command, Uripath, is built on first use because its base class comes from duho.

main(argv=None)

Run one uripath command and return its exit status.

argv is the arguments after the program name (default sys.argv[1:]). Returns 0 on success, 1 when the operation failed, 2 for a wrong invocation and 130 on Ctrl-C. When the reader of standard output went away it returns 1 and prints nothing. Results go to stdout and one uripath: <Type>: <message> line per failure to stderr. Without duho it prints which extra to install and returns 1.

Source code in src/uripath/cli/__init__.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def main(argv: "_ty.Optional[_ty.Sequence[str]]" = None) -> int:
    """Run one `uripath` command and return its exit status.

    `argv` is the arguments after the program name (default `sys.argv[1:]`).
    Returns 0 on success, 1 when the operation failed, 2 for a wrong
    invocation and 130 on Ctrl-C. When the reader of standard output went away
    it returns 1 and prints nothing. Results go to stdout and one `uripath: <Type>: <message>` line per
    failure to stderr. Without `duho` it prints which extra to install and
    returns 1.
    """
    try:
        import duho  # noqa: F401
    except ModuleNotFoundError as error:
        if error.name != "duho":
            raise
        print(_NEEDS_EXTRA, file=_sys.stderr)
        return 1
    from ._root import run

    return run(argv)