Autocompletion for subcommands and arguments

RESOLVED FIXED in Firefox 66

Status

enhancement
RESOLVED FIXED
7 months ago
6 months ago

People

(Reporter: ahal, Assigned: ahal)

Tracking

(Blocks 1 bug)

Trunk
mozilla66
Dependency tree / graph

Firefox Tracking Flags

(firefox66 fixed)

Details

Attachments

(2 attachments)

Mach has a bash completion script here:
https://searchfox.org/mozilla-central/source/python/mach/bash-completion.sh

But it only works for top level commands. It would be great if we could also auto-complete subcommands and even arguments.

I'm not familiar with bash autocompletion, but it looks like this is using the mach mach-commands command to seed the options. Maybe we could add some optional arguments to mach mach-commands, e.g:

$ mach mach-commands
build
mochitest
run
try
...

$ mach mach-commands try
--preset
again
fuzzy
syntax
...

$ mach mach-commands try fuzzy
--artifact
-q
--query
--full
...

Then update the completion script to pass the command/subcommand into mach mach-commands if appropriate.

It would also be great if this was installed by default with mach_bootstrap if possible. istr that I tried to set this up years ago and it didn't work. Also without bootstrap it doesn't help the people who need it most since knowing it exists is already advanced knowledge.

Assignee: nobody → ahal
Status: NEW → ASSIGNED
I was looking for a good place to put documentation for enabling the
bash completion script when I realized that the 'mach' documentation
is targeted at tool developers rather than users.

Seeing as this is the main 'mach' documentation and we want to make
'firefox-source-docs' the place to go for contribution information,
we should endeavour to target end users with this documentation.

This adds a very basic usage page which should be expanded upon, but
is better than nothing.

I changed the headers in 'index.rst' to use raw:: html so that they
don't show up in the nav bar to the left (and subsequently block the
*actually important* things from appearing).
Since we're calling into a mach command for the current completion
implementation anyway (and incurring python startup penalties), we
might as well move all the bash logic into the mach command.

The new 'mach-completion' command was created in case there are
scripts relying on the current behaviour of 'mach-commands'.

Depends on D16254
Pushed by ahalberstadt@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5b651dea28d8
[mach] Add some basic usage docs r=nalexander
https://hg.mozilla.org/integration/autoland/rev/729ea50e3045
[mach] Implement bash completion for subcommands and arguments r=nalexander
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
Blocks: 1190239
Depends on: 1520006
You need to log in before you can comment on or make changes to this bug.