I tried using `target` to create an alias (as desc...
# general
f
I tried using
target
to create an alias (as described in the docs) but looks like that approach only works for depending on that target, not give people a nicer command to run a script:
Copy code
NoApplicableTargetsException: No applicable files or targets matched. The `run` goal works with these target types:

  * pex_binary
  * python_requirement
  * python_source
  * python_test

However, you only specified target arguments with these target types:

  * target
Is there a recommended alternative? Defining a pex-binary where I would have defined the target, but including the source file that the alias would have pointed to?
w
I’m not sure, but are you referring to a CLI alias? Or a BUILD file macro?
f
I am talking about making
pants run my/path/to/some/file/in/a/subfolder/my_script.py
accessible under
pants run less/deep:my_script
. Based on the docs I was hoping to use the
target
for such an alias. But seems such an alias target can only be used a dependency, not with
pants run
b
One approach might be a
[cli.alias]
configured in `pants.toml`: https://www.pantsbuild.org/2.21/docs/using-pants/advanced-target-selection#using-cli-aliases
Copy code
[cli.alias]
run-my-script = "run my/path/to/some/file/in/a/subfolder/my_script.py" # used like `pants run-my-script`
my-script = "my/path/to/some/file/in/a/subfolder/my_script.py" # used like `pants run my-script`
👍 1