Is there any reliable metric for detemining when a...
# general
w
Is there any reliable metric for detemining when a pants command line command is "done"? In the shell completions, if I want to show directories, files, AND completions - it ends up looking like this mess. Hard to tell what's a goal, and what's an extensionless file.
Copy code
3rdparty/                                 build-support/                            experimental-deploy                       internal-generate-test-lockfile-fixtures  peek                                      test
BUILD                                     cargo*                                    experimental-explorer                     java-dump-source-analysis                 publish                                   test.sh
BUILD_ROOT                                check                                     export                                    jvm-symbol-map                            py-constraints                            testprojects/
CODE_OF_CONDUCT.md                        check-default-tools                       export-codegen                            lint                                      pyproject.toml                            tests/
CONTRIBUTING.md                           completions                               filedeps                                  list                                      repl                                      update-build-files
CONTRIBUTORS.md                           conftest.py                               filter                                    package                                   roots                                     version
LICENSE                                   count-loc                                 fmt                                       pants*                                    run                                       
MAINTAINERS.md                            dependees                                 generate-lockfiles                        pants-plugins/                            rust-toolchain                            
README.md                                 dependencies                              help                                      pants.ci.toml                             scala-dump-source-analysis                
auth-acquire                              docs/                                     help-advanced                             pants.toml                                src/                                      
auth-token-info                           experimental-bsp                          help-all                                  paths                                     tailor
Gets a bit better when narrowing, but still 🤷
Copy code
% ./pants t
tailor         test           test.sh        testprojects/  tests/
I've messed around with using targets, but that's very slow right now. I'm also playing around with skipping the filesystem on the first goal, but since we can chain many goals, it gets trickier
Of course, a
./
takes care of a lot of the filesystem-specific problems
g
Just two cents, but my preferred way of command line completion is where I have to guide the completion somewhat instead of being given a million options.
Copy code
pants <tab>           -> goals
pants -<tab>          -> global flags
pants GOAL <tab>      -> paths
pants GOAL PATH:<tab> -> targets
pants GOAL //<tab>    -> targets
pants GOAL -<tab>     -> goal-flags
and so on.
w
Thanks for the input - so right now, it works like this:
Copy code
pants <tab>           -> goals
pants -<tab>          -> global flags
pants GOAL -<tab>     -> goal-flags
pants GOAL <tab>      -> goals and paths
Targets will come down the road. They're a bit trickier, since they'll need to be dynamic completions methinks - and that's slow so I'll want to cleverly cache and that's a problem for later. Right now it's that last completion which is the oddball, because that's where the mingling happens, the reason being, this is perfectly valid:
./pants --changed-since=origin/main fmt lint --some-option check [path/targets]
So, this has me wondering if I should classify each goal as one that will/should directly be followed by a target (introspections mostly) vs chainable?
b
For completions, can we just assumed single goal for simplicity? Alternatively what do similar tools do?
w
For completions, can we just assumed single goal for simplicity?
Thought about it - tried it, didn't like it. Would rather show everything.
Alternatively what do similar tools do?
I've looked at 10-15 other tools, but most of them are a bit more static in their structure - so
tool cmd -options subcmd -options file
I mean, what I have today is already a big improvement over having nothing - but it's yucky when there are a lot of files/backends/plugins
g
What about only completing goals until the user disambiguates? I.e.,
pants GOAL <tab>
gives goals until there's a disambiguation like no-matching-goal or a slash or such?
w
Hmm, how do you mean?
Oh
g
Clarified, lost a word.
IME I know roughly what I want to do with tools like bazel, but there's a lot of typing. But I can do
ba<tab> te<tab> ser<tab>/bac<tab>:de<tab>
to get there faster. And then if I don't know, I still know whether I'm looking for an action or a path so I can disambiguate e.g. with
//
for paths.
(So I guess my point is: I'd find more use with a completion model that helps me find the stuff I know I want rather than showing me stuff I don't know about.)
w
I think that gets confusing for files/targets to show up mid-way, since when youre trying to get the target or file, you'll want the completion immediately. I think I need to test this on some smaller repos, maybe it's not as bad as I think. I just wish there was some easy built-in colouring or some way to distinguish goals from files. Tried to stop auto-sorting
I still know whether I'm looking for an action or a path so I can disambiguate
I agree that once you're a bit more proficient, this is more likely to be the workflow - but a big part of completions is to help the user experience for newer users, who aren't -just- saving time, but might need a crutch to avoid staring at docs all the time
I guess either way, I'm going to try to PR this new goal/option approach so it's readily available - and I think until more people use it, I won't know if this is as bad currently as I think it is, or if I'm just super picky (which I am)
g
Sounds awesome; I'm really looking forward to trying it 🙂 I hear your point re discoverability too; but I think it's pedagogically sound for the completion to guide new users to distinguish goals/targets. I write all of my documentation for Bazel using
//
as a prefix to separate action from object for this reason. But I have colleagues who think that's stupid and I should use short relative paths instead. 😛
h
FWIW I like the idea of only completing goals at least until a first goal has been selected, since a path is not valid at that position anyway
w
Yep, that's implemented right now on my machine - getting filesystem after
./pants
just felt odd