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
Joshua Rubin
ea3df26e64
make shell autocomplete more robust
2016-11-04 14:56:28 -06: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
0c143a2a26
app: Fix trailing space for Author.String()
...
This code initially landed with lots of space:
'{name} <{email}> '
or:
'{name} '
in 3d718330
(app, help: add support for multiple authors, 2015-01-31).
The doubled space between the name and email was removed in c6592bb4
(app, help: add backwards compatibility for Authors, 2015-02-21), but
a trailing space remained in both the email and email-less cases.
This commit removes that trailing space.
2016-10-22 15:58:07 -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
W. Trevor King
c4a46a7df2
app: Add App.Description
...
So you can describe what the application is for without requiring
users to drill down into a particular command.
2016-10-12 08:06:41 -07:00
Jesse Szwedko
a5ca09a934
fixup! remove the possiblity of end-user's seeing deprecation warnings
2016-08-21 14:06:59 -07:00
Jesse Szwedko
8e6aa34a12
remove the possiblity of end-user's seeing deprecation warnings
...
Instead use deprecation pattern described in
https://blog.golang.org/godoc-documenting-go-code .
Fixes #507
2016-08-21 13:51:55 -07: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
Antoine Eiche
7640bef0eb
Add --init-completion flag to print completion code
...
This flag takes as input 'bash' or 'zsh' and generates the completion
code for the specified shell.
2016-07-26 15:32:03 +02:00
Dan Buch
f7b2b93ffa
Merge remote-tracking branch 'origin/v1' into merging-from-v1
2016-07-14 17:50:16 -04:00
Radek Simko
bef215fe3e
app: Allocate Metadata map automatically
2016-07-11 07:39:58 +01: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
5c7afce5b8
Add help command before category scan/sort
2016-06-22 09:34:24 -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
c70993dbc5
Merge branch 'v2' into minimize-struct-copying
2016-05-23 22:08:59 -04:00
Dan Buch
8f25dbb615
Ensure all flag aliases are set when Destination given
...
and extend "Incorrect Usage" message to show the error.
Closes #430
2016-05-23 22:00:59 -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
Jesse Szwedko
024b4c6240
Update references to codegangsta to urfave (new org name)
...
Also add notice to README
2016-05-22 14:42:23 -07: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
81fcf706ea
Replace all "stringly typed" fields with slice equivalents
...
and alter the Flag interface accordingly
Closes #415
2016-05-21 21:29:45 -04:00
Dan Buch
c19dbaf230
Remove deprecated things and supporting code
2016-05-17 15:11:44 -04:00
Matt Farina
07ce8bf79c
Cleaned up else per golint
...
When an if ends in a return the else is not required. golint
detects these conditions and found these.
2016-05-09 10:15:05 -04:00
Matt Farina
2f110bd745
Cleaned up exported func comments per golint
2016-05-09 10:12:59 -04:00
Matt Farina
2f4ec31264
Fixed spelling and gofmt issues
2016-05-09 09:40:09 -04:00
Dan Buch
97d2df6dd7
Merge remote-tracking branch 'origin/master' into psmit-hidden_command
2016-05-08 18:44:38 -04:00
Matt Farina
6f0b442222
Update to ErrWriter and make available on app
2016-05-06 12:14:26 -04:00
Matt Farina
2a256d4c53
Provide a variable for writing output with a default of os.Stderr
2016-05-05 10:26:53 -04: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
4b4c07bd4f
Ensure HandleAction/HandleExitCoder work correctly with *ExitError
...
Closes #376
2016-05-02 11:32:22 -04:00
Gert-Jan Timmer
a90e2e4ff1
Fix #376 NewExitError not working, reflect vals[0] cast to Interface() was missing
2016-05-02 17:06:14 +02:00
e0d7cbbe2c
Merge pull request #372 from codegangsta/deprecation-cleanups
...
Cleaning up the recently-introduced deprecations
2016-05-01 09:18:56 -04:00
Dan Buch
007295e509
Cleaning up the recently-introduced deprecations
...
to ensure the intent, responsibility, and migration path are all more clear.
2016-05-01 09:09:54 -04:00
Dan Buch
fed78b8bab
Rework of hidden flag impl plus some Action func corrections
2016-05-01 08:36:17 -04:00
e671f0b23b
Merge pull request #339 from jack230230/master
...
Add App.Metadata
2016-04-30 09:36:46 -04:00
王振威
f72d405107
Change Extras to Metadata
2016-04-30 10:42:07 +08:00
Dan Buch
06c01a4bba
A few tweaks based on feedback in #361
2016-04-29 03:01:57 -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
b453bf5940
Clarifying errors returned from HandleAction + tests
2016-04-28 11:03:10 -04:00
Dan Buch
271b56c71b
Cleanups based on feedback in #361
2016-04-28 10:15:04 -04:00
Dan Buch
7371138edb
Add back App.RunAndExitOnError with deprecation message
2016-04-27 12:23:09 -04:00
Dan Buch
02924293ff
Removing unused vars
2016-04-27 11:51:41 -04:00
Dan Buch
d45f7c1fe2
Allow for legacy and newer Action func signatures
2016-04-27 11:34:01 -04:00
Dan Buch
f688d47415
Encapsulate ExitCoder check into a lil func
2016-04-27 09:18:42 -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
a17c8cf1d8
Rename func type suffixes Fn
->Func
and add OnUsageErrorFunc
2016-04-25 18:29:05 -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
Felamande
3fb51f15e8
use filepath.Base instead of path.Base in Name & HelpName as default values.
2016-04-03 17:50:08 +08:00
Jesse Szwedko
bc465beccc
Merge pull request #346 from codegangsta/category_sort_2
...
Add option to make categories with command, to display a more structured help
2016-03-26 15:39:47 -07:00
Radek Simko
d21170f0e3
Never show version if HideVersion=true
2016-03-21 16:12:46 +00: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
Soulou
994a7028e2
Categories as slice, not a map anymore, order is always preserved
2016-03-20 11:35:25 -07:00
Soulou
a0801792cc
Allow to sort commands by category
2016-03-20 11:32:58 -07:00
王振威
88ea7cbec8
Add App extras info
2016-03-02 10:45:13 +08: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
Gregor Noczinski
66c1742012
* Fixed typos
2016-02-06 21:39:35 +01:00
Gregor Noczinski
c462071a52
* Added ability to customize usage error messages
2016-02-06 21:39:35 +01:00
leonardyp
6f6e8caf6c
Repeat context statement because of a is a pointer
...
performance optimization
gofmt code
2016-02-04 15:25:41 +08:00
Gregor Noczinski
f3c8e07836
Also show help if App/Command Before produces error.
2015-12-25 22:08:22 +01:00
Yagnesh Mistry
b0b9bd5dac
use path.Base in Name & HelpName as default values
2015-12-18 23:28:32 +05:30
Jacopo
4a8406ac89
Run check completion before error checking
...
Running check completion before error checking allows for completion of flags when no character has been typed yet
2015-12-13 09:39:01 +10:00
Kaushal Subedi
c70ad9b688
fixed tests
2015-10-24 23:51:06 -06:00
Ryan Graham
732e97aee8
only display app version and help message once
...
When processing the flags for -h/--help and -v/--version, only check
the flags in checkVersion() and checkHelp() instead of also printing
the associated message.
This fixes the problem of `app -h` and `app -v` printing their output
twice. The doubling was caused by printing the message once for each
registred alias for the given flags (-h/--help and -v/--version).
Resolves #285
2015-10-18 17:02:23 -07:00
Jesse Szwedko
9039757268
Merge pull request #267 from tristanz/master
...
Add ArgsUsage field to document the use of arguments
2015-10-06 19:45:04 -07:00
Nodir Turakulov
c80fcac42b
Honor HideHelp and HideVersion
...
App.Run does not check a.Hide{Help,Version} before checking it,
as a result customers cannot define their own -v flag (e.g. for verbose)
2015-09-27 23:42:17 -07:00
Tristan Zajonc
c7aac252f1
add tests
2015-08-12 22:14:26 -07:00
Tristan Zajonc
cc46ca1020
allow overriding help name
2015-08-12 21:58:25 -07:00
Tristan Zajonc
aced6e8739
fix tests
2015-08-12 21:43:14 -07:00
Tristan Zajonc
ef65245544
add ArgsUsage to App and Command
2015-08-12 20:00:07 -07:00
Tarcísio Gruppi
49c1229409
Added exit code support
...
Now the exit code can be returned by BeforeFn, ActionFn and AfterFn.
The `os.Exit` function is not called by this packaged
This closes #66 and closes #164
2015-07-28 20:10:08 +02:00
Tarcísio Gruppi
9c0db3f4ac
Created types for functions
...
The function used by BashComplete, Before, After, Action and
CommandNotFound have their won type.
This makes easier to change/update the API
2015-07-28 20:02:18 +02:00
Martin Falatic
ee2cde7a77
Print blank lines in help and error outputs more consistently.
2015-06-24 22:46:33 -07:00
Jesse Szwedko
7ad88c2740
Merge pull request #238 from polds/copyright
...
Add the ability to add a copyright
2015-06-16 19:39:24 -07:00
Mawueli Kofi Adzoe
c7be972e81
Fix tiny typo.
2015-06-11 10:24:06 +00:00
Peter Olds
2726643347
Add the ability to add a copyright
...
Signed-off-by: Peter Olds <polds@kyanicorp.com>
2015-06-09 16:35:50 -06:00
Jesse Szwedko
55b8924c2b
Merge pull request #230 from codegangsta/do-not-swallow-after-error
...
Aggregate errors from Before/After
2015-06-02 20:29:44 -07:00
Jesse Szwedko
7ed7a51f86
Aggregate errors from Before/After
...
Previously `After` would overwrite any error from `Before`.
2015-06-01 21:14:53 -07:00
Fabian Ruff
65d50017d4
search context hierachy for global flags
2015-05-18 23:21:33 +02:00
jszwedko
e842547421
Readd printHelp function back
...
But update signature to take a writer. This is a backwards incompatible
change for those overriding the HelpPrinter, but the hope is that this
feature is largely unused and the usage is easily updated.
2015-05-03 17:43:52 -07:00
2bcd11f863
Merge pull request #193 from codegangsta/add-aliases
...
Add `Command.Aliases` and deprecate `Command.ShortName`
2015-03-16 21:49:33 -04:00
jszwedko
b95607c608
Use named struct fields
2015-03-10 08:13:31 -07:00
jszwedko
7beac44ab1
Don't default authors
2015-03-10 08:03:05 -07:00
jszwedko
5f95a9e88b
Fix support for deprecated author fields
...
Should add an author if either name or email is specified.
2015-03-10 07:59:59 -07:00
jszwedko
bf65971a6a
Add Command.Aliases
and deprecate Command.ShortName
...
`Aliases` will be more flexible while still allowing "ShortName"
behaviour via `Aliases`.
2015-03-09 21:24:57 -07:00
jszwedko
01cdaa065a
Merge remote-tracking branch 'origin/master' into add-multi-author-support
...
Conflicts:
app.go
2015-03-09 19:20:56 -07:00
jhowarth
a6482d2687
Merge remote-tracking branch 'upstream/master'
...
Conflicts:
app.go
command.go
flag.go
2015-03-02 15:21:01 -08:00
jhowarth
6023f370c1
dry error messages
2015-03-02 12:00:21 -08:00
jhowarth
e67e05f617
DRY error handling
2015-03-02 11:56:29 -08:00
jhowarth
cbd95292ac
Remove debugging
2015-03-02 11:18:59 -08:00
Harrison
c6592bb487
app, help: add backwards compatibility for Authors
2015-02-21 10:44:00 +11:00