- fn := cfgTable[os.Args[1]]
- if fn == nil {
- return NewActionResult(fmt.Errorf("internal: no config found for %s", os.Args[1]))
+ nArgs := len(os.Args) - 1 // skip program name
+ if nArgs < 1 {
+ return NewActionResult(fmt.Errorf("internal: no action specified!"))
+ }
+ action := os.Args[1]
+ methodValue := reflect.ValueOf(&actions).MethodByName(action)
+ if !methodValue.IsValid() {
+ return NewActionResult(fmt.Errorf("internal unknown action %s!", action))