Skip to content

Commit

Permalink
feat: update flag
Browse files Browse the repository at this point in the history
  • Loading branch information
miaolz123 committed Sep 28, 2020
1 parent 0810ed1 commit 1064841
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package flag
import (
"os"
"path/filepath"
"sort"

"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -31,14 +32,14 @@ func action(ctx *cli.Context) error {
return nil
}

func Add(flag cli.Flag, fn cli.ActionFunc) {
func Add(flag cli.Flag, acts ...cli.ActionFunc) {
app.Flags = append(app.Flags, flag)
if fn != nil {
actions = append(actions, fn)
}
actions = append(actions, acts...)
}

func Run() error {
app.Flags = append(app.Flags, cli.HelpFlag)
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
return app.Run(os.Args)
}

0 comments on commit 1064841

Please sign in to comment.