go_sysutils/exec_extra/funcs_test.go

28 lines
483 B
Go
Raw Normal View History

2024-06-17 04:33:30 -04:00
package exec_extra
import (
`testing`
)
type (
testStruct struct {
Foo string `cmdarg:"short=f,long=foo"`
Bar int `cmdarg:"short=b,long=bar,prefer_short"`
}
)
func TestGetCmdFromStruct(t *testing.T) {
var err error
var out []string
var v *testStruct = &testStruct{
Foo: "foo",
Bar: 123,
}
if out, err = GetCmdFromStruct(v); err != nil {
t.Fatalf("Received error getting command from struct: %v", err)
}
t.Logf("Got command args from struct:\n%#v", out)
}