Bash::Completion::Plugins::Sqitch - bash completion for Sqitch
# Will install App::Sqitch and Bash::Completion if they aren't installed $ cpanm Bash::Completion::Plugins::Sqitch; # Add newly created Sqitch Bash::Completion plugin to current session. (See # "SETTING UP AUTO-COMPLETE" to permanently add completions for `sqitch`.) $ eval "$(bash-complete setup)" # Magical tab completion for all things Sqitch! (well, kind of - see below) $ sqitch <tab><tab>
Bash::Completion::Plugins::Sqitch is a Bash::Completion plugin for App::Sqitch.
The functionality of this plugin is heavily dependent and modelled around the design of App::Sqitch version 0.9996. As long as App::Sqitch doesn't drastically change, things should be fine. I cannot guarantee that it will work for older versions of App::Sqitch, so update to the latest version if you have any problems.
0.9996
Currently this completion module only returns completions for subcommands (e.g., deploy, verify, revert etc.). It does not return sqitch [options] yet, nor sub-subcommands - I will add them in newer versions.
sqitch [options]
It works by using the App::Sqitch::Command:: namespace to list the sqitch subcommands, and takes advantage of each subcommand providing the Getopt::Long options as accessible methods. As such, this means that the auto-complete candidates should track new subcommands and options that are added or deprecated. Once downside to this is that some of the options that are included in the auto-complete candidate list aren't part of the official $subcommand --help for a particular subcommand.
App::Sqitch::Command::
sqitch
$subcommand --help
N.B., Sqitch auto-completion works best if you're in the sqitch folder (the one with the sqitch.conf and sqitch.plan in it - which is generally how I use it all the time anyway.
sqitch.conf
sqitch.plan
Extended auto-complete options are available in certain circumstances.
$ sqitch target add dev db:pg://username:password@localhost/somedatabase # sqitch.conf ... [target "dev"] uri = db:pg://username:password@localhost/somedatabase ... $ sqitch verify --target <tab><tab>
When the option --target is recognised anywhere in the list of options, the sqitch.conf file is read, and any targets are returned as candidates.
--target
targets
N.B., this extra requires that your cwd is the sqitch directory with the sqitch.plan file.
cwd
# .bashrc or .bash_profile # # auto-complete won't work for the [database] with the default # COMP_WORDBREAKS, as such I globally remove `:` and `=`. This isn't for # everyone - but this extra will *not* work without doing it. export COMP_WORDBREAKS=${COMP_WORDBREAKS/:/} export COMP_WORDBREAKS=${COMP_WORDBREAKS/=/} $ sqitch status db:pg:<tab><tab>
I'm hoping this is more useful in the future because there is a bug with most of the useful sqitch subcommands in that they don't honour the service paramenter in the [database] string. It works for status though!
service
[database]
N.B., this currently only works for the pg engine as it uses Pg::ServiceFile to autocomplete the database based on the service names.
pg
database
The instructions for setting up Bash::Completion don't work under all Perl environments - particularly plenv. The instructions below should work.
# Stick this into your .bashrc or .bash_profile eval "$(bash-complete setup)"
# Stick this into your .zshrc autoload -U bashcompinit bashcompinit eval "$(bash-complete setup)"
Paul Williams <kwakwa@cpan.org>
Copyright 2018- Paul Williams
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
App::Sqitch, Bash::Completion.
To install Bash::Completion::Plugins::Sqitch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bash::Completion::Plugins::Sqitch
CPAN shell
perl -MCPAN -e shell install Bash::Completion::Plugins::Sqitch
For more information on module installation, please visit the detailed CPAN module installation guide.