Add a bash-completion script #22

aleksejrs opened this Issue Aug 17, 2012 · 6 comments


None yet

3 participants


mozdownload has multiple command line switches, some of which are only available in the long form.
mozdownload also has 43-line help output.

bash-completion allows for auto-completion of command line options of a program when using bash or zsh. For example, git provides a 56-kilobyte description of completion in Debian (most auto-completion scripts are only a couple kilobytes though). With it, you can enter “mozdownload --”, press Tab, and see a concise list of all the available long switches; or you can enter also a couple of letters of a switch and press Tab and have that switch completed.

Most of the auto-completion scripts are written in bash itself, but there is a Perl support script, and at least one program to generate one based on Python's optparse syntax (possibly supporting or ported to argparse).


I found this from I see that python optcomplete module can be used to provide automatic completion. I have forked the repo and making the changes.

Description of planned changes (Let me know if you see any issues)

  • Update to add dependency on the optcomplete python package (
  • Update code in to use optcomplete as suggested by optcomplete documentation.

After these two changes, user has to follow the optcomplete documentation to source a bash function and then to tell Bash to trigger optcomplete completion for the specific programs that use it:

complete -F _optcomplete <program>

Python also has argparse and argcomplete. But the Option Group is not so straightforward (atleast to me) in the argparse. The is using Option Group for different build (candidate, daily and tinderbox) options.

I will be doing manual testing on zsh and bash for the auto-completion of two or more options. I will also run the automated tests and make sure that they pass.


I ended up not using optcomplete. During changes, I realized it is too much for just the simple cli switches completion.

I ended up updating the to provide all the options when called with the environment containing _MOZDOWNLOADARGCOMPLETE. This is the same strategy which optcomplete and argcomplete use.

I also added a bash_completion.d/ which provides the bash completion. This is similar to argcomplete bash_completion.d file. The addition of new file needed updates in the to include package_data.

I have all the changes done in my fork. I have manually tested auto-completion in bash and it works fine. I also ran the tests using and they worked as well.

How do I go about getting the changes reviewed and then eventually make them to this repo to get this issue fixed?


code is available for review. Please see the pull request.

@jayrajput jayrajput was assigned by whimboo Jun 13, 2014
whimboo commented Jun 13, 2014

Good to see that you picked that issue Jay! I will get to it soon. For now I will make you the assignee.

whimboo commented Jun 13, 2014

The referenced PR #221 was the mixture with another PR. So after talking to Jay he split out the code for this issue. So I will wait for the next PR you are opening.

@whimboo whimboo added the blocked label Mar 11, 2015
whimboo commented Mar 11, 2015

An implementation here would be blocked by issue #269.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment