Commit Graph

118 Commits

Author SHA1 Message Date
Dan Buch
df5c6caa96
Back out the testify/assert addition 😅 2017-08-04 12:43:16 -04:00
Dan Buch
47a412375f
Resolved compile-time errors since merging from v1 2017-08-04 12:00:22 -04:00
Dan Buch
a61867e5e6
Merge remote-tracking branch 'origin/v1' into merging-from-v1 2017-08-04 11:59:27 -04:00
Joe Richey joerichey@google.com
1794792adf Add ability to use custom Flag types
Users can now use custom flags types (conforming to the Flag interface)
in their applications. They can also use custom flags for the three
global flags (Help, Version, bash completion).
2017-05-05 22:24:14 -07:00
Kasey Klipsch
8fa549846e #556 broke the api for users who were using the ActionFunc 2016-11-21 09:47:23 -06:00
Joshua Rubin
2da42640ad
Merge remote-tracking branch 'origin/master' into completion_fix 2016-11-18 09:28:39 -07:00
Joshua Rubin
3272baf434
add a test for shell completion using incomplete flags 2016-11-14 10:10:51 -07:00
Jesse Szwedko
e367fafa3d Return an error when parsing environment variables for values fails
Currently cli silently (aside from IntSlice and Int64Slice which oddly
printed directly to the error stream) ignores failures that occur when
parsing environment variables for their value for flags that define
environment variables. Instead, we should propogate up the error to the
user.

This is accomplished in a backwards compatible manner by adding a new,
internal, interface which defines an applyWithError function that all
flags here define. In v2, when we can modify the interface, we can drop
this secondary interface and modify `Apply` to return an error.
2016-11-13 14:59:35 -08:00
Jesse Szwedko
0113f56d10 If no action is specified on the command or app, print the help documentation
Rather than panic'ing or displaying an opaque error message about the
signature which is more confusing to the end user.

Fixes #562
2016-11-12 13:37:07 -08:00
Jesse Szwedko
b377b5d9e9 Use type assertions rather than reflection to determine how to call the Action
This has some benefits, but results in possibly less informative error
messaging; however, given that there are only two accepted types,
I think the error messaging is sufficient.
2016-11-01 20:33:12 -07:00
Jesse Szwedko
61db37e7ae Merge branch 'master' into default-writer 2016-10-29 18:36:19 -07:00
Jesse Szwedko
83497d2cda Merge remote-tracking branch 'origin/master' into v2-merge 2016-10-29 14:13:18 -07:00
Jesse Szwedko
f614c177b7 Merge pull request #543 from wking/app-description
app: Add App.Description
2016-10-25 21:54:02 -07:00
W. Trevor King
3c2bce5807 help: Cleanup AppHelpTemplate trailing whitespace
Most of the changes here remove trailing whitespace, but I also add
code to select "AUTHOR" or "AUTHORS" as appropriate instead of the
previous "AUTHOR(S)".  The template for listing with an entry per line
is:

   {{range $index, $entry := pipeline}}{{if $index}}
   {{end}}{{$entry}}{{end}}

That range syntax is discussed in [1].

Also add a unit test, which tests both these whitespace changes and
also the earlier App.Description addition.

[1]: https://golang.org/pkg/text/template/#hdr-Variables
2016-10-22 16:02:21 -07:00
Richard Kovacs
4cc2bad36e Display error instead of just say command is incorrect 2016-10-19 13:31:05 +02:00
Jesse Szwedko
508a23430b Default app.Writer to os.Stdout
As NewApp() does.

Fixes #545
2016-10-18 20:56:31 -07:00
lewo
6aa0ab6903 Merge branch 'v2' into v2-completion 2016-09-01 09:35:02 +02:00
Dan Buch
81c242dda6
Merge remote-tracking branch 'origin/master' into merging-from-v1 2016-08-22 14:41:56 -04:00
Antoine Eiche
94bc26fd1c Refactoring names from bash to shell
The refactoring is required since completion is also supported for zsh
shell.

Refactoring details:
- flag generate-bash-completion -> generate-completion
- var  EnableBashCompletion     -> EnableShellCompletion
- var  BashComplete             -> ShellComplete
- var  BashCompletionFlag       -> GenerateCompletionFlag
- type BashCompleteFunc         -> ShellCompleteFunc
2016-07-26 15:32:03 +02:00
Dan Buch
dd253d122c
Write err to stderr, exit 1 if err != ""
Closes #475
2016-07-24 11:57:51 -04:00
Dan Buch
f7b2b93ffa
Merge remote-tracking branch 'origin/v1' into merging-from-v1 2016-07-14 17:50:16 -04:00
Jesse Szwedko
65da20beab Correctly show help message if -h is provided to subcommand
Currently, if an action is specified on a subcommand, it ignores the
`-h` and `--help` flags if passed to the subcommand, e.g.:

`foo bar -h`

would call the default action on `bar` rather than show the help
documentation.

Fixes #477
2016-07-13 14:48:16 -07:00
Dan Buch
99621d571e
Merge remote-tracking branch 'origin/v2' into declarativeness 2016-06-22 23:07:20 -04:00
Dan Buch
df685fbacc
Remove NewApp initializer
and move defaulting to `App.Setup`
2016-06-22 12:47:57 -04:00
Dan Buch
0f135b318e
Merge remote-tracking branch 'origin/v1' into merging-from-v1 2016-06-22 12:03:21 -04:00
Dan Buch
3c5afd4757
Hide help command for category tests 2016-06-22 09:48:39 -04:00
Dan Buch
5a3515fdf8
Focus on catching fewer panics in HandleAction
so that "unknown" panics can still bubble up.
2016-06-09 17:32:00 -04:00
Dan Buch
3d75e9e711
Go with interfaces + private opaque types
rather than public types that wrap slices
2016-05-25 12:05:14 -04:00
Dan Buch
61710ff108
Make slice wrapping pattern more consistent
and move *Args out into its own file
2016-05-23 20:15:35 -04:00
Dan Buch
cd10b49473
Minimize struct copying
by using pointer func receivers and slices of struct pointers where possible.
2016-05-22 15:20:52 -04:00
Dan Buch
c19dbaf230
Remove deprecated things and supporting code 2016-05-17 15:11:44 -04:00
Dan Buch
32ebecfbb5
Merge remote-tracking branch 'origin/master' into v2 2016-05-09 11:18:21 -04:00
Matt Farina
2f4ec31264 Fixed spelling and gofmt issues 2016-05-09 09:40:09 -04:00
Dan Buch
bac790c819
Merge remote-tracking branch 'origin/master' into v2 2016-05-09 08:00:13 -04:00
Dan Buch
dfa9a87bee
Add tests for App.VisibleCategories & App.VisibleCommands 2016-05-08 23:54:12 -04:00
Jesse Szwedko
f585ec7cb8 Remove reordering of flags and arguments
This was introduced by #36, but only worked in the specific case of all
arguments being passed before all flags. If the user mixed them, they
ended up with odd parsing behavior where the arguments were reordered
(causing #103 and #355).

Given the tradeoffs I think we should remove support for flag
reordering.

Fixes #103
Fixes #355
2016-05-07 16:36:54 -07:00
Dan Buch
cc481d6b0e
Adjust command hiding to use similar convention as hidden flags
plus breaking out "setup" portion of `App.Run` into its own method, cleaning up
some bits of the help templates, and allowing for runtime opt-in of displaying
template errors to stderr.
2016-05-03 06:54:05 -04:00
Dan Buch
1fb52b3bce
Merge remote-tracking branch 'origin/master' into string-slice-flag-default-160 2016-04-30 13:13:02 -04:00
Dan Buch
4cae17cfe1
Ensure MultiError returned when both Before and After funcs given 2016-04-28 17:15:16 -04:00
Dan Buch
ee736e063a
Merge remote-tracking branch 'origin/master' into string-slice-flag-default-160 2016-04-28 16:53:45 -04:00
Dan Buch
61d4175525
Merge remote-tracking branch 'origin/master' into txgruppi-develop 2016-04-28 16:20:02 -04:00
Dan Buch
2c0e13ecf8
Revising/adding tests that assert order of operations inside App.Run 2016-04-28 16:05:14 -04:00
Dan Buch
b453bf5940
Clarifying errors returned from HandleAction + tests 2016-04-28 11:03:10 -04:00
Dan Buch
b7329f4968
Switch from multi-return with exit codes to ExitCoder check 2016-04-27 09:12:34 -04:00
Dan Buch
10c8309d84
Merge branch 'develop' of https://github.com/txgruppi/cli into txgruppi-develop 2016-04-25 18:10:10 -04:00
Dan Buch
cb433e7468 Use NewIntSlice and NewStringSlice internally 2016-04-05 22:38:31 -04:00
Jesse Szwedko
042842b819 Remove CategorizedHelp from App and allow subcommands to have categories
Just place all subcommands in categories, the default category will be
"" which will properly format the output (and group commands that have
no category).

Also allow subcommands to have categories.

Lastly, augment the test to check the output.
2016-03-20 12:17:13 -07:00
Soulou
d0997e8f99 Set Categories as a read-only method and fix tests 2016-03-20 11:35:26 -07:00
adamclerk
cde8418658 Fixes spelling issues and import alphabetical issues
Using goreportcard.com I noticed a few spelling errors. I really love codegangsta/cli
and wanted to help improve it.
2016-02-09 09:36:13 -07:00
Jesse Szwedko
d5f087da9d Merge pull request #289 from KSubedi/master
Added command to have a custom text on the USAGE section of help
2016-02-06 13:12:10 -08:00