https://pantsbuild.org/ logo
#general
Title
# general
e

eager-crayon-52125

04/29/2022, 10:11 AM
Q: is there a bash autocomplete for pants? Ideally with target names as well.
βœ… 1
c

curved-television-6568

04/29/2022, 10:14 AM
Not yet for Pants v2 unfortunately https://github.com/pantsbuild/pants/issues/11187
e

eager-crayon-52125

04/29/2022, 10:19 AM
Thanks Andreas. Is it "in the pipe", or should I hack something quick and ugly just for myself?
c

curved-television-6568

04/29/2022, 10:20 AM
I don’t know of anyone working, or planning to work on, this right now. So a quick and dirty hack may be worthwhile for you, if you want this sooner rather than later. πŸ˜‰
If it turns out not too hackish, PRs are always welcome πŸ™‚
e

eager-crayon-52125

04/29/2022, 10:25 AM
So together with the fact that I must invoke pants from the repo root, I feel this becomes more important. I don't imagine it'll be something not hackish though. My thoughts: 1. It'll be a bash script that will eventually run pants from the repo root. 2. The first version will have just target name completions, and will understand target names that start with //, with :, or have a colon in them. It will complete them on the command-line using pants query. (I imagine there's something like that?) 3. The shell script will invoke pants with the expanded target, or simply append $CWD before the target if I don't want to fully/relatively expand it on the command line. 4. At a later stage, if that works, I can think of added common goal names, or scrape them from
pants help
any thoughts on this?
(and thanks for taking the time here!)
πŸ‘Œ 1
c

curved-television-6568

04/29/2022, 10:26 AM
No problem at all.
There’s
./pants peek
to query for target data as defined in your BUILD files.
And
./pants help-all
gives you all available help data in json format.
e

eager-crayon-52125

04/29/2022, 10:29 AM
Great, looks like the right building blocks. I'll take a peek, pun intended πŸ™‚
πŸ˜‚ 1
πŸ‘ 1
e

enough-analyst-54434

04/29/2022, 2:17 PM
Shell completion will be good to have (back - Tom added it for v1 iirc). That said, you can mostly get address completion for free by avoiding addresses and using built-in shell completion of paths. Throw in a
:
or
::
glob at the end of the dir completion or complete all the way through to the file name if appropriate. That gets me almost all I need using Pants on pants itself anyhow.
πŸ‘ 1
e

eager-crayon-52125

04/30/2022, 4:09 PM
@enough-analyst-54434, @bitter-ability-32190 -- since you expressed some interest in shell completion: I hacked something for myself, and I'm wondering you think folks would like to give it a go. It's nothing like production grade I assume, but it one file and one line of .bashrc, and if it sees a wider audience I think other people using it would be the first step. So it's more of a question: do you think I should write something in #general? How would you propose going about this?
b

bitter-ability-32190

04/30/2022, 4:34 PM
Post a gist! See what others think 😊
e

eager-crayon-52125

04/30/2022, 5:17 PM
Cool. Here goes...
5 Views