Commit Graph
22 Commits
Author SHA1 Message Date
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
Anthony Fok c65e6422ff Fix typo: exiting → existing 2015-12-17 14:43:23 -07:00
Anthony Fok c3ef89ad8a Fix typo: initalize → initialize, etc.
Detected by Debian’s Lintian tool
2015-12-17 11:18:55 -07:00
Anthony Fok 4b096512f3 Reflow license text and add copyright year and name
* Format license text and header to fit within 80 characters per line
 * Remove extra top line from LICENSE file for Apache-2.0
 * Remove the FreeBSD-specific disclaimer from the BSD-2-Clause license
 * Use {{ .copyright }} to add "Copyright © YEAR FULL NAME" to the
   LICENSE file for MIT and BSD licenses.
2015-11-21 23:37:58 -07:00
Anthony Fok 6d6c92d5b7 Parse the full license text as a template
... to allow including "Copyright © 2015 NAME HERE" to the output
LICENSE file where necessary
2015-11-21 23:29:20 -07:00
Anthony Fok 10546a043b Remove extraneous comma at the end of SEE ALSO list 2015-11-21 06:23:56 -07:00
Anthony Fok 9c32fb42ec Reset man page title when necessary in GenManTree
If the user did not define header.Title when calling GenManTree(),
reset it after each call to GenMan(), otherwise the entire man page tree
would be stuck with the full command name that was calculated for the
first man page, leaving all subsequent man pages with an identical
but incorrect title.
2015-11-21 06:18:37 -07:00
Anthony Fok 3bd84ba55c Ensure man page title is uppercase and has rootcmd
As described in http://man7.org/linux/man-pages/man7/man-pages.7.html
2015-11-21 06:13:53 -07:00
Anthony Fok baf44a3923 Fix Lintian warning: manpage-has-bad-whatis-entry
This patch fixes the problem where lexgrog fails to parse the NAME section
when the provided command contains space, e.g. "rootcmd subcmd".

Explanation from Lintian:

 Each manual page should start with a "NAME" section, which lists the
 name and a brief description of the page separated by "\-".  The "NAME"
 section is parsed by lexgrog and used to generate a database that's
 queried by commands like apropos and whatis.  This tag indicates that
 lexgrog was unable to parse the NAME section of this manual page.

 For manual pages that document multiple programs, functions, files, or
 other things, the part before "\-" should list each separated by a comma
 and a space.  Each thing listed must not contain spaces; a man page for a
 two-part command like "fs listacl" must use something like "fs_listacl"
 in the "NAME" section so that it can be parsed by lexgrog.

Ref: lexgrog(1), groff_man(7), groff_mdoc(7)
2015-11-21 06:12:14 -07:00
Anthony Fok 46c720088b Fix a copy-and-paste error in man_docs.md
Thanks to @goern for reporting the error.

Fixes #188
2015-11-20 17:12:30 -07:00
Anthony Fok 0cc7cc2c06 Fix typo in cobra/cmd/init.go 2015-11-20 15:50:06 -07:00
Anthony Fok 4e18e0c2bf Fix typos in README.md: Change "it's" to "its" where appropriate 2015-11-20 15:31:48 -07:00
Anthony Fok 1e63ad8ed1 Fine-tune the formatting of Cobra’s generated code 2015-11-20 15:28:40 -07:00
Anthony Fok c7feee9f20 Add .mailcap for a more tidy "git shortlog" output 2015-11-20 15:24:23 -07:00
Anthony Fok 1f03277811 Fix minor typos in cobra_test.go 2015-11-20 15:23:16 -07:00
Anthony Fok 9324f3657d Copyedit README.md 2015-11-15 00:28:22 -07:00
Anthony Fok e5762054c9 Limit the verbose test workaround to "cobra.test" only
so that full path to the executable or a renamed executable
parses command-line arguments correctly as before.

Special thanks to @apriendeau for discovering "go test -v" failing
and for providing the initial workaround, see #155 and subsequent
discussions.
2015-11-07 23:21:50 -07: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
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
Anthony Fok 4745f1fd64 In execute(), check if command is Runnable()
A corner case exists where c.Runnable() is not checked
before c.Run() is called, thus a nil c.Run is executed
leading to "panic: runtime error: invalid memory address
or nil pointer dereference".

This patch adds an extra c.Runnable() check in execute()
to catch that corner case.

Fixes #37.
2014-12-18 22:46:33 -05:00