Skip to content

Commit

Permalink
little
Browse files Browse the repository at this point in the history
  • Loading branch information
nikandfor committed Apr 28, 2023
1 parent ddcf321 commit fdf5f3b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type (
Args Args // must be initialized to cli.Args{} if arguments expected
Env []string // env vars not used for local flags

Chosen *Command // chosen command

// User options

Name string // comma separated list of aliases
Expand Down Expand Up @@ -186,6 +188,7 @@ func (c *Command) run(args, env []string) (err error) {
}

if sub := c.Command(arg); sub != nil {
c.Chosen = sub
err = sub.run(args, c.Env)

return errors.WrapNoCaller(err, MainName(arg))
Expand Down
1 change: 0 additions & 1 deletion flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func New(name string, val interface{}, help string, opts ...Option) (f *Flag) {
case []string:
f.Action = ParseStringSlice
case Setter:
f.Value = nil
f.Action = ParseSetter(val, true, false)
default:
panic(fmt.Sprintf("unsupported value type: %T", val))
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions flag/flag_options.go → flag/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import (
"github.com/nikandfor/errors"
)

func Default(v interface{}) Option {
return func(f *Flag) {
f.Value = v
}
}

func Hidden(f *Flag) {
f.Hidden = true
}
Expand Down

0 comments on commit fdf5f3b

Please sign in to comment.