Skip to content
Commit 1d694b28 authored by Chandan Singh's avatar Chandan Singh Committed by Tristan Van Berkom
Browse files

_artifactcache/pushreceive.py: Add Click type for CLI argument 'repo'

The CLI for `bst-artifact-receive` expects a `repo` argument, which is
supposed to be a directory, but Click currently expects it to be just
any string. This results in stack traces like the one below when the
argument provided is not a directory:

        $ ~/.local/bin/bst-artifact-receive --pull-url http://foo foobaz
        Traceback (most recent call last):
          File "/root/.local/bin/bst-artifact-receive", line 8, in <module>
            sys.exit(receive_main())
          ...
          File "/src/buildstream/buildstream/_artifactcache/pushreceive.py", line 581, in __init__
            self.repo.open(None)
        GLib.Error: g-io-error-quark: /src/buildstream/43fref: opendir(/src/buildstream/foobaz): No such file or directory (1)

Add types for this argument such that it throws better error messages
when it receives bad arguments. With the Click types added, it will
instead fail with messages like these:

        $ ~/.local/bin/bst-artifact-receive --pull-url http://foo foobaz
        Usage: bst-artifact-receive [OPTIONS] REPO

        Error: Invalid value for "repo": Directory "foobaz" does not exist.

        $ ~/.local/bin/bst-artifact-receive --pull-url http://foo setup.py
        Usage: bst-artifact-receive [OPTIONS] REPO

        Error: Invalid value for "repo": Directory "setup.py" is a file.

Fixes #409.
parent 8d88b52a
Loading
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment