Commit Graph

625 Commits

Author SHA1 Message Date
Albert Nigmatzianov 4cdb38c072 cmd: Use correct HasPrefix function for paths
Updates #448
2017-05-15 09:51:20 +02:00
Albert Nigmatzianov e9078fccb8 cmd: Make more accurate error when there is no $GOPATH 2017-05-15 09:20:36 +02:00
Albert Nigmatzianov fa9ac853ce cmd: Make detailed error when project not in $GOPATH
Updates #448
2017-05-15 08:37:15 +02:00
Albert Nigmatzianov 51b7cf57e1 Fix tests so they give correct args (#445)
* Fix tests so they give correct args

Shell already deletes all quotes and unite args under quotes, so we
don't need to test it.

* Simplify stripFlags

* Fix 'unused' and 'gosimple' complaints
2017-05-14 08:51:04 -04:00
Albert Nigmatzianov b5366273a6 cmd: Fix some gometalinter complaints 2017-05-14 12:27:15 +02:00
Albert Nigmatzianov d9414968f8 cmd: Fix error message from go-homedir 2017-05-14 12:03:16 +02:00
Behrang Noruzi Niya a28055bed2 cmd: Fix minor bugs in init command (#446) 2017-05-14 12:00:53 +02:00
Don Petersen 90687e7bfc Update pflag link in README (#444)
Cobra is not using ogier/pflag, but a fork of it.
2017-05-12 20:40:24 +02:00
Albert Nigmatzianov 7d22e77cce Fix incorrect merge of pflag.CommandLine to cmd.Flags()
Fix #443
2017-05-12 20:22:26 +02:00
Albert Nigmatzianov 3454e0e28e cmd: Fix package name when adding command 2017-05-12 12:10:33 +02:00
G. Hussain Chinoy 4673102358 Updating bash_completions to clarify markdown (#442)
"Plural form and shortcuts for nouns" section had a stray backtick, making Markdown rendering for code examples strange. Removed said backtick.
2017-05-11 17:04:35 +02:00
Albert Nigmatzianov 1362f95a8d Clean README.md (#441)
The release notes are obsolete and we better have a release notes
in Github releases

We don't need this TODO as we have godoc

And bitdeli doesn't work and doesn't supported for about 3 years.
2017-05-09 16:18:58 -04:00
Eric Paris 347767f8bd Partial revert of 4d2c4af 'Improve template mechanism' (#439)
There were template functions which we defined and others started using.
Although we no longer want those functions, since others use them,
deleting them breaks our API.  Putting those (unused) functions back.
2017-05-09 15:07:05 -04:00
Albert Nigmatzianov eceb483eb5 Divide fields of Command for readability 2017-05-09 11:33:56 +02:00
Albert Nigmatzianov 90d2fd84ad Group fields of Command 2017-05-09 11:25:41 +02:00
Albert Nigmatzianov 1251aefb74 Rename Docker to Moby in README.md 2017-05-09 11:19:15 +02:00
Albert Nigmatzianov e97db2b866 cmd: Fix tests 2017-05-09 11:15:48 +02:00
Albert Nigmatzianov 4db577d34d Fix docs for Command 2017-05-09 11:15:05 +02:00
Albert Nigmatzianov 6bfe2ba1a2 doc: Add docs 2017-05-09 11:14:48 +02:00
Albert Nigmatzianov 3dc7f13b65 cmd: Fix docs 2017-05-09 11:14:33 +02:00
Albert Nigmatzianov d236d29810 cmd: Make tmpl local variable
Fix CircleCI tests
2017-05-08 23:00:14 +02:00
Adrián López c0bd07d7ba Use cobra create instead of cobra init in README.md (#396) 2017-05-08 14:23:08 +02:00
Albert Nigmatzianov 4d2c4afa04 Improve template mechanisms
* Delete Eq, Gt, appendIfNotPresent and trim functions

* Add "[flags]" in UseLine

* Simplify other functions

* Simplify templates

Minor performance improvement.
Benchmark for command with 4 flags and one child command:
benchmark                   old ns/op     new ns/op     delta
BenchmarkCmdUsageFunc-4     335860        319290        -4.93%

benchmark                   old allocs     new allocs     delta
BenchmarkCmdUsageFunc-4     562            543            -3.38%

benchmark                   old bytes     new bytes     delta
BenchmarkCmdUsageFunc-4     21623         21037         -2.71%
2017-05-08 14:22:04 +02:00
Albert Nigmatzianov d83a1d7ccd Add comment for InitDefaultHelpFlag 2017-05-07 10:52:40 +02:00
Albert Nigmatzianov fe69f2e3a3 Make initHelpFlag public
Used for solving #424
2017-05-07 00:45:39 +02:00
Albert Nigmatzianov db6b9a8b3f cmd: Fix incorrect initialzation by `cobra init .`
Close #314
2017-05-05 10:51:57 +02:00
Albert Nigmatzianov 7bd35d3b95 cmd: Fix incorrect cmd dir 2017-05-05 10:35:27 +02:00
Albert Nigmatzianov 7bb5276f5f cmd: Fix panic if cmd ends on dash or underscore 2017-05-05 10:35:27 +02:00
Albert Nigmatzianov efbe9b05d8 cmd: Use Fatalf instead of Fatal 2017-05-05 10:35:27 +02:00
Albert Nigmatzianov 76a9a66775 cmd: Add tests 2017-05-05 10:35:27 +02:00
Albert Nigmatzianov d20925b932 cmd: Small correctives 2017-05-05 10:35:27 +02:00
Albert Nigmatzianov 84cba621a0 cmd: Make detection of $HOME work on all systems
Use github.com/mitchellh/go-homedir

Fix #430
2017-05-05 10:35:27 +02:00
Albert Nigmatzianov 6bcf163261 cmd: Validate cmd names
Fix #269
2017-05-05 10:35:27 +02:00
Albert Nigmatzianov 903e5b7073 cmd: Fix trimSrcPath doc 2017-05-05 10:35:27 +02:00
Albert Nigmatzianov 66cfd1f132 cmd: Reuse template in helpers 2017-05-05 10:35:27 +02:00
Albert Nigmatzianov 0dd1c429a3 cmd: Add more docs 2017-05-05 10:35:27 +02:00
Albert Nigmatzianov 32756eb440 cmd: Rewrite 2017-05-05 10:35:27 +02:00
Albert Nigmatzianov 4061f41c9a Use pflag.ShorthandLookup 2017-05-05 08:08:38 +02:00
Albert Nigmatzianov 8f0203be89 Update README.md 2017-05-02 08:49:35 +02:00
Albert Nigmatzianov 69f86e6d5d Update README.md
See #269
2017-05-01 23:08:34 +02:00
Albert Nigmatzianov 6f647b1711 Update .travis.yml
Delete obsolete versions and update Go 1.8 to Go 1.8.1
2017-05-01 22:56:13 +02:00
Angel Beltran bc8a58ff4d docs: Update README.md 2017-05-01 16:51:43 +02:00
Albert Nigmatzianov 7b1b6e8dc0 cmd: Edit license texts 2017-04-27 20:09:18 +02:00
Albert Nigmatzianov e2f2121008 cmd: Use 'this program' instead of appName in licenses 2017-04-27 20:09:18 +02:00
Albert Nigmatzianov 3d7bff8a32 Revert "Get rid of flagErrorBuf (#417)"
This reverts commit b655df6ce8.

Reason for revert: duplicate errors from flag. More in #426

Fix #426
2017-04-27 15:10:57 +02:00
Albert Nigmatzianov 6dd90846ba doc: Use w.Write instead of fmt in yaml_docs
benchmark                        old ns/op     new ns/op     delta
BenchmarkGenYamlToFile-4         62488         61622         -1.39%

benchmark                        old allocs     new allocs     delta
BenchmarkGenYamlToFile-4         121            120            -0.83%

benchmark                        old bytes     new bytes     delta
BenchmarkGenYamlToFile-4         26706         26280         -1.60%
2017-04-26 21:30:17 +02:00
Albert Nigmatzianov 97af803f3b doc: Cleanup md_docs
Performance gain:
benchmark                        old ns/op     new ns/op     delta
BenchmarkGenMarkdownToFile-4     23096         10295         -55.43%

benchmark                        old allocs     new allocs     delta
BenchmarkGenMarkdownToFile-4     47             48             +2.13%

benchmark                        old bytes     new bytes     delta
BenchmarkGenMarkdownToFile-4     1984          2832          +42.74%
2017-04-26 21:30:17 +02:00
Albert Nigmatzianov de484eefb4 doc: Refactor man docs
Performance impact (very strange):
benchmark                        old ns/op     new ns/op     delta
BenchmarkGenManToFile-4          30037         29001         -3.45%

benchmark                        old allocs     new allocs     delta
BenchmarkGenManToFile-4          77             89             +15.58%

benchmark                        old bytes     new bytes     delta
BenchmarkGenManToFile-4          9075          9651          +6.35%
2017-04-26 21:30:17 +02:00
Albert Nigmatzianov ea3c5beeff Add TestHelpFlagInHelp 2017-04-26 21:24:14 +02:00
Albert Nigmatzianov 867d414548 Initialize help flag in initHelpCmd
Fix #302
2017-04-26 21:24:14 +02:00