Is there any easy way to check that all aliases de...
# general
h
Is there any easy way to check that all aliases defined in
pants.toml
are valid references to targets?
e
You don't mean these do you?: https://www.pantsbuild.org/docs/reference-cli#alias Those need not reference a target at all. Or do you mean target in a more generic sense outside the standard Pants vocab?
h
I do mean those. Referencing a target was the wrong word, but basically make sure that they actually alias a real thing
Our typical use case is to alias something like
run really/long/random/path/to/some/cli.py --
down to
helpful_cli
so users can just do
pants helpful_cli <args>
We had a scenario where the path was wrong because someone rearranged tooling and didn't get discovered for a while
e
I don't think so right now in general using Pants. If the goal is invalid or the path is goal-like, no slashes, then
./pants foo --help
where foo is the alias
foo = "glug"
or
foo = "test glug"
will ferret out a failure but if the alias is
foo = "test glug/baz/does/not/exist"
- the
--help
trick doesn't help.
Pants used to have an
alias
target to do what you talk about here. Basically a target that was immediately de-referenced to the target it pointed at - exactly for this path shortening trick. That went away in the v1 -> v2 transition though.
Those could be auto-checked with a small script to either list alias targets or filedeps them.
h
Yeah, I'll probably just make something simple to grab the toml, get all our aliases and check them individually.
It's an interesting problem when aliases could literally be anything from a complete, self-contained command to one that expects extra input from the user
Even testing ours would require adding
--help
to the end of most of ours.
e
The glug example should be informative. If you just want to test paths, you can ignore tokens without
/
or starting with
--
and the remaining should all be paths or targets you can probably just try a
./pants list
on.