Commit Graph
36 Commits
Author SHA1 Message Date
Anthony Fok 893ebf6e36 Fix typo 2021-02-10 12:40:59 -07:00
Anthony Fok be1efc850f Update CHANGELOG.md for v1.1.3 2021-02-10 12:35:57 -07:00
Anthony Fok 7f95502478 Update CHANGELOG.md for v1.1.2 2021-02-09 18:39:00 -07:00
Anthony Fok 07445ea179 Copyedit shell-completion related documentation 2021-02-09 14:08:42 -07:00
Anthony Fok 1135bdeceb Update gopkg.in/yaml.v2 to v2.4.0
The previous breaking change in yaml.v2 v2.3.0 has been reverted,
see https://github.com/go-yaml/yaml/pull/670
2021-02-01 12:44:33 -07:00
Anthony Fok b26b538f69 Fix remaining reproducibility in TestGoldenAddCmd
My previous fix in PR #504 was incomplete.

Fixes #503
2017-07-31 11:04:27 -06:00
Anthony Fok 9e024b655b cmd: Refine formatting of included licenses 2017-07-30 02:35:06 -06:00
Anthony Fok a1b7d3cc4d cmd: Add a blank line between copyright and license 2017-07-30 02:15:55 -06:00
Anthony Fok 75c6acfc8f cmd: Add "-u" to output unified diff in golden tests 2017-07-30 02:11:56 -06:00
Anthony Fok cb9cf94690 Restore the use of cobra.OnInitialize in cobra executable
Without cobra.OnInitialize, cobra does not see the --config
command-line option and always tries to load $HOME/.cobra.yaml
instead.
2017-07-30 01:19:17 -06:00
Anthony Fok d4c40bbacf travis: Update Go versions 2017-07-30 00:20:54 -06:00
Anthony Fok 750ba8ac93 Fix reproducibility in TestGolden{Add,Init}Cmd
These tests were time-dependent and would start failing in 2018
when the golden files still have the copyright year of 2017.

Fix by hard-coding the year 2017 for the purpose of these two tests
to ensure reproducible builds.

Fixes #503
2017-07-30 00:17:45 -06:00
Anthony Fok 161584fc2e Fix minor typos: "Know" → "Known" 2017-07-29 22:49:33 -06:00
Anthony Fok 34594c771f Fix TestGlobalNormFuncPropagation() on gccgo
According to golang/go#9504 and https://golang.org/pkg/reflect/#Value,
== should not be used on two reflect.Values, but comparing the results
of their Interface() method does not work in this case, so let's
compare the results of their Pointer() method instead.

See https://stackoverflow.com/questions/9643205/how-do-i-compare-two-functions-for-pointer-equality-in-the-latest-go-weekly
2017-07-25 14:04:38 +02: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
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