Skip to content

Commit

Permalink
Merge branch 'master' into asahasrabuddhe-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
asahasrabuddhe committed Sep 11, 2019
2 parents 71eaf37 + 61f3ae3 commit ef47250
Show file tree
Hide file tree
Showing 32 changed files with 1,518 additions and 2,212 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ before_script:
- go mod tidy

script:
- go run build.go generate
- go run build.go vet
- go run build.go test
- go run build.go gfmrun
Expand Down
3 changes: 0 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ install:
- set PATH=%GOPATH%\bin;C:\go\bin;%PATH%
- go version
- go env
- go get github.com/shurcooL/vfsgen
- go get github.com/shurcooL/httpfs/union
- go get github.com/urfave/gfmrun/...
- go get -v -t ./...

build_script:
- go run build.go generate
- go run build.go vet
- go run build.go test
- go run build.go gfmrun
23 changes: 0 additions & 23 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ func main() {
Name: "toc",
Action: TocActionFunc,
},
cli.Command{
Name: "generate",
Action: GenActionFunc,
},
}

err := app.Run(os.Args)
Expand Down Expand Up @@ -166,22 +162,3 @@ func TocActionFunc(_ *cli.Context) error {

return nil
}

func GenActionFunc(_ *cli.Context) error {
err := runCmd("go", "generate", "flag-gen/main.go")
if err != nil {
return err
}

err = runCmd("go", "generate", "cli.go")
if err != nil {
return err
}

err = runCmd("git", "diff", "--exit-code")
if err != nil {
return err
}

return nil
}
17 changes: 14 additions & 3 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,20 @@ func checkRequiredFlags(flags []Flag, context *Context) requiredFlagsErr {
var missingFlags []string
for _, f := range flags {
if rf, ok := f.(RequiredFlag); ok && rf.IsRequired() {
key := strings.Split(f.GetName(), ",")[0]
if !context.IsSet(key) {
missingFlags = append(missingFlags, key)
var flagPresent bool
var flagName string
for _, key := range strings.Split(f.GetName(), ",") {
if len(key) > 1 {
flagName = key
}

if context.IsSet(strings.TrimSpace(key)) {
flagPresent = true
}
}

if !flagPresent && flagName != "" {
missingFlags = append(missingFlags, flagName)
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,20 @@ func TestCheckRequiredFlags(t *testing.T) {
},
parseInput: []string{"--requiredFlag", "myinput", "--requiredFlagTwo", "myinput"},
},
{
testCase: "required_flag_with_short_name",
flags: []Flag{
StringSliceFlag{Name: "names, N", Required: true},
},
parseInput: []string{"-N", "asd", "-N", "qwe"},
},
{
testCase: "required_flag_with_multiple_short_names",
flags: []Flag{
StringSliceFlag{Name: "names, N, n", Required: true},
},
parseInput: []string{"-n", "asd", "-n", "qwe"},
},
}
for _, test := range tdata {
t.Run(test.testCase, func(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func testApp() *App {
Usage: "retrieve generic information",
}, {
Name: "some-command",
}, {
Name: "hidden-command",
Hidden: true,
}}
app.UsageText = "app [first_arg] [second_arg]"
app.Usage = "Some app"
Expand Down
4 changes: 4 additions & 0 deletions fish.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func (a *App) prepareFishCommands(commands []Command, allCommands *[]string, pre
for i := range commands {
command := &commands[i]

if command.Hidden {
continue
}

var completion strings.Builder
completion.WriteString(fmt.Sprintf(
"complete -r -c %s -n '%s' -a '%s'",
Expand Down
1 change: 0 additions & 1 deletion flag-gen/.gitignore

This file was deleted.

55 changes: 0 additions & 55 deletions flag-gen/assets_generate.go

This file was deleted.

214 changes: 0 additions & 214 deletions flag-gen/assets_vfsdata.go

This file was deleted.

0 comments on commit ef47250

Please sign in to comment.