Commit Graph

81 Commits

Author SHA1 Message Date
Dr. Stefan Schimanski 1a0a490d76 Remove plural handling and add aliases for nouns in completion 2016-04-02 12:39:19 +02:00
Dr. Stefan Schimanski a23d903a12 Fix escaping of % in bash code strings 2016-03-22 17:44:59 +01:00
Dr. Stefan Schimanski ea9a77d312 Add support for plural nouns in bash completion 2016-03-21 08:05:54 +01:00
Dr. Stefan Schimanski 8092588fb8 Add custom bash flag completion 2016-03-21 08:05:54 +01:00
Dr. Stefan Schimanski 7d556a0974 Enable bash completion after --flag= or --flag=abc 2016-03-21 08:05:49 +01:00
Anthony Fok 65a708cee0 Allow bash-completion to work with full-path executable 2016-02-08 17:06:27 -05:00
Anthony Fok 801364aa15 Skip "bash: declare: -A: invalid option" error gracefully
The use of "declare -A flaghash" (associative array) was introduced
in PR #205, which works perfectly for Bash 4.x, but OS X insists on
shipping a very outdated Bash 3.2.x.

This patch hides the "bash: declare: -A: invalid option" error message
and allows the bash completion script to continue gracefully on
OS X, albeit without the benefit of the new feature in PR #205.

Fixes #240
2016-02-05 13:04:36 +08:00
Anthony Fok 97f831a4fd Change first line of generated bash-completion file
to conform with existing bash-completion snippets and
to suppress Lintian "script-not-executable".
2016-01-11 15:37:32 -07:00
Daniel Martí e0479ff7a7 Add error handling to GenBashCompletion
Since the switch from *bytes.Buffer to io.Writer, errors can no longer
be ignored. Also makes the reuse of GenBashCompletion in
GenBashCompletionFile without a buffer treat errors properly again.
2016-01-05 21:31:19 +01:00
Daniel Martí a5ff2f28ab Reuse GenBashCompletion in GenBashCompletionFile 2016-01-05 21:30:42 +01:00
Daniel Martí 463be1428d Replace *bytes.Buffer with io.Writer
Also adds support for generating bash completions on writers other than
just buffers.

Found via github.com/mvdan/interfacer.
2016-01-05 21:30:42 +01:00
Tamer TAS c6399cd398 Use readline's default filename completion if completion fails
If the `compspec` generates no matches it uses bash filename completion instead.
2016-01-02 08:11:35 +02:00
Kenjiro Nakayama 60b8213eba Add flaghash to bash_completion to keep flag value 2015-12-24 08:53:30 -05:00
Adam Bozanich fe79245d1a Bash completion for names with ':' character. 2015-12-09 20:57:45 -08:00
Anthony Fok 0e4c02d9cb Restore bash completion behaviour for bash 4.x
In Pull Request #178, the use of `builtin compopt` as a test condition
is inappropriate.  Use `[[ $(type -t compopt) = "builtin" ]]` instead.

Also clean up formatting of the resulting bash completion script.
2015-11-07 04:39:28 -07:00
Fabiano Franz 7290a944e4 Allow marking persistent flags as required or filename 2015-11-06 08:43:09 -05:00
Fabiano Franz dab963a797 Persistent flags should also be used in completions 2015-11-06 08:43:09 -05:00
Eric Paris 2e6a428921 Merge pull request #179 from eparis/init_comp
Check for _init_completion not_init_completionS
2015-11-03 15:41:40 -05:00
Matt McCoy 428babeb31 Modifying bash completions so they can run on OSX 2015-11-03 15:21:24 -05:00
Eric Paris 58e38f95da Check for _init_completion not_init_completionS 2015-11-03 15:09:37 -05:00
Eric Paris 3eac1434ef Update IsAvailableCommand checks
This slightly changes IsAvailableCommand in that a non-runnable command
with a runnable subcommand is now 'Available'

We also use IsAvailableCommand in the rest of the codebase instead of
half kinda sorta doing it incorrectly other places.
2015-09-08 22:48:12 -04:00
Eric Paris 32e87e3c8e Enable bash completions on Macs
If they installed bash-completions from homebrew, this should make our
completions work.
2015-09-03 17:00:18 -04:00
Eric Paris 9e7788657f Auto generation of a man page 2015-08-21 01:10:13 -07:00
Anthony Fok 1e6fdf608f Add new BashCompSubdirsInDir annotation
This first `cd` to a specified directory, then
lists the subdirectories therein with `_filedir -d`.

This can be used by e.g. `hugo --theme=[Tab][Tab]`, which would
give a list of subdirectories under the `themes` directory.
2015-08-09 13:30:58 -06:00
Jordan Liggitt 6119fc993e Simplify setting file/extension annotations on a flag 2015-06-22 15:16:00 -04:00
Eric Paris dff410ab56 make filename extension handling a bash function
We were trying to call a bash function with bash stuff like @ () from a
variable.  Stop that.  Just call a function with an arg from a variable
instead of trying to pass around the bash.

Should fix https://github.com/spf13/cobra/pull/103
2015-05-04 18:41:53 -04:00
Eric Paris f4b3401f9e Clean up minor bash complaints from shellcheck.net 2015-05-04 14:40:27 -04:00
Eric Paris c3e48f996d Deprecated subcommands
They should still work, but shouldn't show up in help or usage output
2015-04-29 13:08:20 -04:00
Eric Paris 0fc734c3c5 Sort the valid args before output
We do this so we get stable repeatable output and can see if updates are
necessary or if it is just golang doing the same thing twice differently
2015-04-13 18:44:05 -04:00
Eric Paris a068307565 add a helper to annotate a flag as 'required' by a command 2015-04-07 20:14:18 -04:00
Eric Paris 9b2e6822e5 Add bash autocompletion generator
Given a (potentially annotated) cobra command you can generate a bash
completion script.
2015-04-07 20:13:49 -04:00