Added a wrapper function to execute the Fn of a device. Runs the ArgCheck too
This commit is contained in:
@@ -58,6 +58,17 @@ type DeviceCMD struct {
|
||||
Fn DeviceCMDFn
|
||||
}
|
||||
|
||||
func (dCMD *DeviceCMD) Run(args []string) (types.Command, []byte, error) {
|
||||
// Validate the arguments in the device function
|
||||
err := dCMD.ArgCheck(args)
|
||||
if err != nil {
|
||||
return 0, []byte{}, err
|
||||
}
|
||||
|
||||
// Run the function
|
||||
return dCMD.Fn(dCMD, args)
|
||||
}
|
||||
|
||||
func (dCMD *DeviceCMD) GetIdentifier() types.Command {
|
||||
return dCMD.Identifier
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user