28 lines
483 B
Go
28 lines
483 B
Go
|
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)
|
||
|
}
|