Commit Graph

136 Commits

Author SHA1 Message Date
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
Gregor Noczinski
c462071a52 * Added ability to customize usage error messages 2016-02-06 21:39:35 +01:00
Andreas Kupries
bb4e78eb6a Fixed mishandling of a "-"(dash)-argument causing reordering of cli non-flag arguments.
Added test demonstrating issue (PASS with fix, FAIL without).
2016-01-26 15:34:53 -08:00
Gregor Noczinski
f90cd56647 Handle Before and After of Command without handling it as subCommand if there is no subCommand. 2015-12-25 21:45:58 +01:00
Håvard Haugen
7b94fd3aad test: avoid output from "go test" when tests pass
Some tests where printing to os.Stdout as a side effect even if the
output was not used/checked in the test.
2015-11-28 18:26:10 +01:00
Jesse Szwedko
4fc241fb17 Update examples to use correct naming convention
See https://golang.org/pkg/testing/#hdr-Examples
2015-11-15 13:14:11 -08:00
Kaushal Subedi
c70ad9b688 fixed tests 2015-10-24 23:51:06 -06:00
Tristan Zajonc
c7aac252f1 add tests 2015-08-12 22:14:26 -07:00
Tristan Zajonc
aced6e8739 fix tests 2015-08-12 21:43:14 -07:00
Tarcísio Gruppi
1510d7e722
Updated tests to support exit code 2015-07-28 20:29:13 +02:00
Edward Sheffler III
8ea1232ede Improve vendoring options by removing self-referential imports in tests. 2015-07-20 12:28:51 -07:00
Brian Goff
758ad1e836 Sets a subcommand's parent cmd
This allows the help output to show the correct/full command path to the
subcommand.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-07-02 14:47:49 -04:00
Fabian Ruff
a2d4ae5939 Fix global flags processing on top level
This fixes a regression introduced by #227. When looking up global flags by walking up the parent context's we need to consider the special case when we are starting at the very top and there is no parent context to start the traversal.

Fixes #252
2015-06-29 23:20:27 +02:00
Dan Buch
4407569431 Merge branch 'master' into fix-231 2015-06-11 01:23:20 -04: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
2272dad83e Version and help check should look for local flags too
Now that Global looks up the chain of contexts, the top level should
access the flags without the prefix (i.e. Bool rather than GlobalBool).
2015-06-02 20:16:44 -07:00
Jesse Szwedko
854c52192c Merge pull request #227 from databus23/global-flags-from-all-parents
Collect global flags from the full command hierarchy
2015-06-01 21:25:30 -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
Sergey Romanov
f47f7b7e85 Fix panic if Valus in Int/StringSliceFlasg is missing 2015-06-01 01:50:23 +05:00
Fabian Ruff
65d50017d4 search context hierachy for global flags 2015-05-18 23:21:33 +02:00
jszwedko
b8104e5da7 Set writer when running command as app
Also add test from https://github.com/codegangsta/cli/pull/202 with
slight modifications.
2015-05-03 18:37:51 -07: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
jszwedko
daad50e530 Turns out I didn't mean to add ExampleAppCommands at all 2015-03-16 18:48:06 -07:00
jszwedko
474646abed Didn't mean to remove ExampleAppSubcommand
Also specify struct field initializers
2015-03-16 18:04:57 -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
Harrison
c6592bb487 app, help: add backwards compatibility for Authors 2015-02-21 10:44:00 +11:00
Jesse Szwedko
532d0bc2e3 Merge pull request #151 from imdario/master
After: companion action for Before
2015-02-20 16:20:12 -05:00
Harrison
05ecd63a95 app_test: prepare for PR 2015-01-31 10:05:45 +11:00
Harrison
3d7183307a app, help: add support for multiple authors 2015-01-31 10:04:52 +11:00
Dario Castañé
4e3a83b43e Merge branch 'master' of https://github.com/codegangsta/cli
Conflicts:
	app.go
	app_test.go
2015-01-10 00:35:11 +01:00
jszwedko
5159b98cbc Use parsed context when running command as subcommnd
Rather than passing the unparsed context (parent context) in whenever
there are no subcommands.
2015-01-09 14:46:29 -05:00
Jesse Szwedko
bf4a526f48 Merge pull request #157 from dajulia3/pull_request
stop flag parsing after terminator --
2015-01-09 14:04:33 -05:00
5b9e204508 Merge pull request #153 from codegangsta/allow-hiding-of-help-flag
Allow hiding of help flag without hiding help subcommand
2015-01-08 14:49:36 -05:00
Matthew McNew
d05d895492 stop flag parsing after terminator --
Signed-off-by: David Wadden <dwadden@pivotal.io>
2014-12-17 09:56:05 -06:00
jszwedko
69b84ea804 Renaming fakeWriter to mockWriter for consistency 2014-12-10 10:33:59 -05:00
jszwedko
b8c8282de5 Merge remote-tracking branch 'origin/master' into allow-writer-to-be-set
Conflicts:
	app.go
	help.go
2014-12-01 23:51:35 -05:00
jszwedko
0d4870d63e Rename Stdout -> Writer 2014-12-01 23:50:04 -05:00
jszwedko
780f839a02 Allow hiding of help flag without hiding help subcommand
By utilizing struct zero value
2014-12-01 23:21:22 -05:00
Dario Castañé
ba22f2189a Changing back cli import in app_test.go 2014-11-19 00:28:57 +01:00
Dario Castañé
3c4b583fee Action error shadowing avoided on After 2014-11-18 23:54:27 +01:00
Dario Castañé
44efc2952d Added Before method to command and app 2014-11-18 23:44:21 +01:00
Josh Mervine
089def51d8 Tweaking tests, removing local import. 2014-08-04 11:30:13 -07:00
Josh Mervine
120f0688a4 Merge remote-tracking branch 'parent/master'
Conflicts:
	cli_test.go
	flag_test.go
2014-08-04 11:25:45 -07:00
e8939d2aa0 Merge remote-tracking branch 'origin/master' into env-config-fun
Conflicts:
	README.md
	app_test.go
	cli_test.go
2014-07-15 16:54:29 -04:00
Audrius Butkevicius
9e036e08f1 Fix tests 2014-07-13 18:52:30 +01:00
jszwedko
bcfb32b8b0 Updating tests to pass go vet
Mostly lack of struct field names in literals and one sprintf format
specifier mismatch.
2014-07-11 18:16:19 -04:00
fc16c67be3 Updating structs to use labels, adding tests for env stuff 2014-07-11 18:13:10 -04:00
Philippe Lafoucrière
df5fb46048 Fix global flags in Subcommands
closes #69
2014-07-06 11:04:48 +02:00
Josh Mervine
8f55ca83ff running go fmt 2014-06-17 22:33:30 -07:00
Joshua Mervine
5821632000 Adding VersionPrinter and tests. 2014-06-17 22:26:35 -07:00
John Hopper
60e3dcaf6d Allow a writer to be set that represents Stdout so that redirection of App output may occur. 2014-06-12 02:27:15 -07:00
Jeremy Saenz
5e1cde20d3 Merge pull request #75 from Winslett/command-not-found
Customizable command not found function
2014-04-22 20:33:49 -07:00
Summer Mousa
705994c2c6 Added unit tests 2014-04-16 12:59:34 -05:00
Summer Mousa
85c3eadea4 Adding sample test 2014-04-12 17:13:47 -05:00
Chris Winslett
37299d4e5a Customizable command not found function 2014-03-30 20:46:02 -07:00
Mr Rogers
b4d98765bd rollback inconsequential changes 2014-02-19 16:38:51 -05:00
Mr Rogers
1ccba5fbb5 fix whitespace 2014-02-19 16:37:20 -05:00
Mr Rogers
a70d0bb136 add tests for description output 2014-02-19 16:32:01 -05:00
Tim Jarratt
58bfabca6d Add a way to override the app help printer
Fixes #64
2014-02-04 08:40:06 -08:00
Greg B
78d5f0dd40 Unit tests for Before() functionality 2014-01-06 15:06:31 -08:00
Katrina Owen
2ec51afe91 Implement Float64Flag. See #46 2013-12-03 05:42:26 -08:00
Alexander Rødseth
1bea6dcbf0 Custom type for arguments 2013-11-24 14:40:21 +01:00
Alexander Rødseth
f93652a890 Fixed all problems/warnings reported by "go vet" 2013-11-15 11:35:24 +01:00
Jeremy Saenz
e6e641143c JMS #39: App.Run returns an error 2013-11-01 07:33:15 -07:00
Thesyncim
ed96efff1b add simple test , fix errors and unused interface SliceFlag 2013-09-24 20:36:01 +01:00
Damien Le Berrigaud
5d511c7a8b Allow for flags being passed in after arguments 2013-09-18 10:37:03 -06:00
Jeremy Saenz
e5c31ab592 JMS-34: App.Run() can now be run multiple times.
- Added a method for looking up commands
- Using some logic to make sure default flags are not added more than
  once
2013-09-14 16:10:38 -07:00
Jeremy Saenz
ed1ee94250 Adding some docs 2013-07-20 15:50:13 -07:00