Create a custom artifact-ref click parameter type
As part of #773 (closed), we will need to update the semantics of how element
types are treated in the CLI. Currently, they are all click.Path
, but it's not guaranteed that click.Path
validation will always allow any artifact ref, so technically there's a chance that BuildStream rejects certain artifact refs on some non-Unix OSs (although I suspect that BuildStream would break much more horribly in such cases anyway). If we change the type to something like str
, however, we lose completion.
We should create a custom click type to handle artifact refs. This would also allow implementing auto completion for artifact refs, which is something we want to do for #773 (closed) anyway.
To resolve this issue, we'd need to:
-
Create an Artifact
click.ParamType
and use it throughoutcli.py
where it makes sense, without regressing file name completion. -
Add artifact ref completion for this type.
The first part should be relatively doable, and can land without the second part. So it may be worth trying if you're a newcomer :)
Relevant discussion from !1497 (merged):
-
@tlater started a discussion: (+2 comments) Sorry, I went and thought about this some more.
We should be doing this:
type=str)
Why? Well, click verifies that the
Path
is a correct file path. We don't want that, since an artifact ref may be an invalid file path (or well, in theory we could change the artifact ref format to allow invalid file paths, or we may run on an OS where they are).Ideally, we should create a custom type that is an artifact ref that could be either a file name or a ref, but I'm ok with just making this a
str
. It should not be aPath
anymore, though.
Note that this is not possible since we still rely on click.Path
for completion.