Releases: leaanthony/clir
Releases · leaanthony/clir
v1.7.0
What's Changed
- feat: Call a given function after calling the command (PostRun) by @GreyXor in #21
- add slice flags by @zkep in #23
Example:
StringsDefault []string `name:"strings_default" description:"The strings default" default:"one|two|three" sep:"|"
New Contributors
Full Changelog: v1.6.0...v1.7.0
v1.6.0
- Support positional arguments using the
pos
struct tag:
type PosPerson struct {
Name string `description:"The name of the person" pos:"1"`
Admin bool `description:"Is the person an admin" pos:"2"`
}
func TestCli_PositionalArgs(t *testing.T) {
c := NewCli("test", "test positional args", "0")
c.NewSubCommandFunction("create", "create a person", func(person *PosPerson) error {
if person.Name != "bob" {
t.Errorf("expected 'bob', got '%v'", person.Name)
}
if person.Admin != true {
t.Errorf("expected true, got %v", person.Admin)
}
return nil
})
e := c.Run("create", "bob", "true")
if e != nil {
t.Errorf("unexpected error")
}
}
v1.5.0
- Add
default
struct tag so you can define default values for cli flags. See https://clir.leaanthony.com/guide/subcommands/#adding-subcommands-with-functions
v1.4.0
- Support Int64, Uint, Uint64, Float64
v1.3.0
- Support flags in embedded structs
v1.2.1
- Fix crash in
AddFlags
if input has unexported fields
v1.2.0
- New method to rapidly add sub commands:
NewSubCommandFunction
. Bind a function to a subcommand name and the function input gets automatically converted to CLI flags in the same wayAddFlags
works. The method is automatically called with the CLI flags. Specify default flags using an optionalDefault()
method on your flags struct: https://clir.leaanthony.com/guide/subcommands/#adding-subcommands-with-functions
v1.1.0
- New
AddFlags
command to add flags using a struct. Details here: https://clir.leaanthony.com/guide/flags/#defining-flags-using-a-struct
v1.0.6
What's Changed
- Feature: subcommands flags inherence by @thetechpanda in #18
New Contributors
- @thetechpanda made their first contribution in #18
Full Changelog: v1.0.5...v1.0.6