Merge remote-tracking branch 'origin/master' into v2
This commit is contained in:
commit
cab5c58774
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.coverprofile
|
11
.travis.yml
11
.travis.yml
@ -1,4 +1,5 @@
|
|||||||
language: go
|
language: go
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
go:
|
go:
|
||||||
@ -8,16 +9,16 @@ go:
|
|||||||
- 1.4
|
- 1.4
|
||||||
- 1.5.4
|
- 1.5.4
|
||||||
- 1.6.2
|
- 1.6.2
|
||||||
- tip
|
- master
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- go: tip
|
- go: master
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- go get github.com/meatballhat/gfmxr/...
|
- go get github.com/meatballhat/gfmxr/...
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- go vet ./...
|
- ./runtests vet
|
||||||
- go test -v ./...
|
- ./runtests test
|
||||||
- gfmxr -c $(grep -c 'package main' README.md) -s README.md
|
- ./runtests gfmxr
|
||||||
|
@ -19,6 +19,11 @@
|
|||||||
for this reordering.
|
for this reordering.
|
||||||
|
|
||||||
## [Unreleased] - (1.x series)
|
## [Unreleased] - (1.x series)
|
||||||
|
### Added
|
||||||
|
- `./runtests` test runner with coverage tracking by default
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Printing of command aliases in help text
|
||||||
|
|
||||||
## [1.17.0] - 2016-05-09
|
## [1.17.0] - 2016-05-09
|
||||||
### Added
|
### Added
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
[![Coverage](http://gocover.io/_badge/github.com/codegangsta/cli?0)](http://gocover.io/github.com/codegangsta/cli)
|
|
||||||
[![Build Status](https://travis-ci.org/codegangsta/cli.svg?branch=master)](https://travis-ci.org/codegangsta/cli)
|
[![Build Status](https://travis-ci.org/codegangsta/cli.svg?branch=master)](https://travis-ci.org/codegangsta/cli)
|
||||||
[![GoDoc](https://godoc.org/github.com/codegangsta/cli?status.svg)](https://godoc.org/github.com/codegangsta/cli)
|
[![GoDoc](https://godoc.org/github.com/codegangsta/cli?status.svg)](https://godoc.org/github.com/codegangsta/cli)
|
||||||
[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-codegangsta-cli)
|
[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-codegangsta-cli)
|
||||||
[![Go Report Card](https://goreportcard.com/badge/codegangsta/cli)](https://goreportcard.com/report/codegangsta/cli)
|
[![Go Report Card](https://goreportcard.com/badge/codegangsta/cli)](https://goreportcard.com/report/codegangsta/cli)
|
||||||
|
[![top level coverage](https://gocover.io/_badge/github.com/codegangsta/cli?0 "top level coverage")](http://gocover.io/github.com/codegangsta/cli) /
|
||||||
|
[![altsrc coverage](https://gocover.io/_badge/github.com/codegangsta/cli/altsrc?0 "altsrc coverage")](http://gocover.io/github.com/codegangsta/cli/altsrc)
|
||||||
|
|
||||||
|
|
||||||
# cli
|
# cli
|
||||||
|
|
||||||
|
4
help.go
4
help.go
@ -26,7 +26,7 @@ AUTHOR(S):
|
|||||||
{{end}}{{if .VisibleCommands}}
|
{{end}}{{if .VisibleCommands}}
|
||||||
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
||||||
{{.Name}}:{{end}}{{range .VisibleCommands}}
|
{{.Name}}:{{end}}{{range .VisibleCommands}}
|
||||||
{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{"\t"}}{{.Usage}}{{end}}
|
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}
|
||||||
{{end}}{{end}}{{if .VisibleFlags}}
|
{{end}}{{end}}{{if .VisibleFlags}}
|
||||||
GLOBAL OPTIONS:
|
GLOBAL OPTIONS:
|
||||||
{{range .VisibleFlags}}{{.}}
|
{{range .VisibleFlags}}{{.}}
|
||||||
@ -67,7 +67,7 @@ USAGE:
|
|||||||
|
|
||||||
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
||||||
{{.Name}}:{{end}}{{range .VisibleCommands}}
|
{{.Name}}:{{end}}{{range .VisibleCommands}}
|
||||||
{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{"\t"}}{{.Usage}}{{end}}
|
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}
|
||||||
{{end}}{{if .VisibleFlags}}
|
{{end}}{{if .VisibleFlags}}
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
{{range .VisibleFlags}}{{.}}
|
{{range .VisibleFlags}}{{.}}
|
||||||
|
70
help_test.go
70
help_test.go
@ -169,6 +169,76 @@ func Test_helpSubcommand_Action_ErrorIfNoTopic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestShowAppHelp_CommandAliases(t *testing.T) {
|
||||||
|
app := &App{
|
||||||
|
Commands: []Command{
|
||||||
|
{
|
||||||
|
Name: "frobbly",
|
||||||
|
Aliases: []string{"fr", "frob"},
|
||||||
|
Action: func(ctx *Context) error {
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
output := &bytes.Buffer{}
|
||||||
|
app.Writer = output
|
||||||
|
app.Run([]string{"foo", "--help"})
|
||||||
|
|
||||||
|
if !strings.Contains(output.String(), "frobbly, fr, frob") {
|
||||||
|
t.Errorf("expected output to include all command aliases; got: %q", output.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestShowCommandHelp_CommandAliases(t *testing.T) {
|
||||||
|
app := &App{
|
||||||
|
Commands: []Command{
|
||||||
|
{
|
||||||
|
Name: "frobbly",
|
||||||
|
Aliases: []string{"fr", "frob", "bork"},
|
||||||
|
Action: func(ctx *Context) error {
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
output := &bytes.Buffer{}
|
||||||
|
app.Writer = output
|
||||||
|
app.Run([]string{"foo", "help", "fr"})
|
||||||
|
|
||||||
|
if !strings.Contains(output.String(), "frobbly") {
|
||||||
|
t.Errorf("expected output to include command name; got: %q", output.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.Contains(output.String(), "bork") {
|
||||||
|
t.Errorf("expected output to exclude command aliases; got: %q", output.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestShowSubcommandHelp_CommandAliases(t *testing.T) {
|
||||||
|
app := &App{
|
||||||
|
Commands: []Command{
|
||||||
|
{
|
||||||
|
Name: "frobbly",
|
||||||
|
Aliases: []string{"fr", "frob", "bork"},
|
||||||
|
Action: func(ctx *Context) error {
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
output := &bytes.Buffer{}
|
||||||
|
app.Writer = output
|
||||||
|
app.Run([]string{"foo", "help"})
|
||||||
|
|
||||||
|
if !strings.Contains(output.String(), "frobbly, fr, frob, bork") {
|
||||||
|
t.Errorf("expected output to include all command aliases; got: %q", output.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestShowAppHelp_HiddenCommand(t *testing.T) {
|
func TestShowAppHelp_HiddenCommand(t *testing.T) {
|
||||||
app := &App{
|
app := &App{
|
||||||
Commands: []Command{
|
Commands: []Command{
|
||||||
|
95
runtests
Executable file
95
runtests
Executable file
@ -0,0 +1,95 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from subprocess import check_call, check_output
|
||||||
|
|
||||||
|
|
||||||
|
PACKAGE_NAME = os.environ.get(
|
||||||
|
'CLI_PACKAGE_NAME', 'github.com/codegangsta/cli'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def main(sysargs=sys.argv[:]):
|
||||||
|
targets = {
|
||||||
|
'vet': _vet,
|
||||||
|
'test': _test,
|
||||||
|
'gfmxr': _gfmxr
|
||||||
|
}
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument(
|
||||||
|
'target', nargs='?', choices=tuple(targets.keys()), default='test'
|
||||||
|
)
|
||||||
|
args = parser.parse_args(sysargs[1:])
|
||||||
|
|
||||||
|
targets[args.target]()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def _test():
|
||||||
|
if check_output('go version'.split()).split()[2] < 'go1.2':
|
||||||
|
_run('go test -v ./...'.split())
|
||||||
|
return
|
||||||
|
|
||||||
|
coverprofiles = []
|
||||||
|
for subpackage in ['', 'altsrc']:
|
||||||
|
coverprofile = 'cli.coverprofile'
|
||||||
|
if subpackage != '':
|
||||||
|
coverprofile = '{}.coverprofile'.format(subpackage)
|
||||||
|
|
||||||
|
coverprofiles.append(coverprofile)
|
||||||
|
|
||||||
|
_run('go test -v'.split() + [
|
||||||
|
'-coverprofile={}'.format(coverprofile),
|
||||||
|
('{}/{}'.format(PACKAGE_NAME, subpackage)).rstrip('/')
|
||||||
|
])
|
||||||
|
|
||||||
|
combined = _combine_coverprofiles(coverprofiles)
|
||||||
|
_run('go tool cover -func={}'.format(combined.name).split())
|
||||||
|
combined.close()
|
||||||
|
|
||||||
|
|
||||||
|
def _gfmxr():
|
||||||
|
_run(['gfmxr', '-c', str(_gfmxr_count()), '-s', 'README.md'])
|
||||||
|
|
||||||
|
|
||||||
|
def _vet():
|
||||||
|
_run('go vet ./...'.split())
|
||||||
|
|
||||||
|
|
||||||
|
def _run(command):
|
||||||
|
print('runtests: {}'.format(' '.join(command)), file=sys.stderr)
|
||||||
|
check_call(command)
|
||||||
|
|
||||||
|
|
||||||
|
def _gfmxr_count():
|
||||||
|
with open('README.md') as infile:
|
||||||
|
lines = infile.read().splitlines()
|
||||||
|
return len(filter(_is_go_runnable, lines))
|
||||||
|
|
||||||
|
|
||||||
|
def _is_go_runnable(line):
|
||||||
|
return line.startswith('package main')
|
||||||
|
|
||||||
|
|
||||||
|
def _combine_coverprofiles(coverprofiles):
|
||||||
|
combined = tempfile.NamedTemporaryFile(suffix='.coverprofile')
|
||||||
|
combined.write('mode: set\n')
|
||||||
|
|
||||||
|
for coverprofile in coverprofiles:
|
||||||
|
with open(coverprofile, 'r') as infile:
|
||||||
|
for line in infile.readlines():
|
||||||
|
if not line.startswith('mode: '):
|
||||||
|
combined.write(line)
|
||||||
|
|
||||||
|
combined.flush()
|
||||||
|
return combined
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
Loading…
Reference in New Issue
Block a user