// FromConfig creates a command struct from the given config
FromConfig creates a command struct from the given config
// FromConfig creates a command struct from the given config
func (command *Command) FromConfig(stepConfig map[string]interface{}) error {
	command.Kind = KindCommand
	if description, ok := stepConfig["Description"]; ok {
		command.Description = description.(string)
	}
	preferencesYaml := stepConfig[fieldNamePreferences].(map[string]interface{})
	command.Command = preferencesYaml[fieldNameCommand].(string)
	if argsYaml, ok := preferencesYaml[fieldNameArgs].([]interface{}); ok {
		var args []string
		for _, arg := range argsYaml {
			args = append(args, arg.(string))
		}
		command.Args = args
	}
	if path, ok := preferencesYaml[fieldNamePath].(string); ok {
		command.Path = path
	} else {
		command.Path = ""
	}
	if silent, ok := preferencesYaml[fieldNameSilent].(bool); ok {
		command.Silent = silent
	} else {
		silent = false
	}
	return nil
}
func ( command * Command ) FromConfig ( stepConfig map [ string ] interface { } ) error { command . Kind = KindCommand if description , ok := stepConfig [ " " ] ; ok { command . Description = description . ( string ) } preferencesYaml := stepConfig [ fieldNamePreferences ] . ( map [ string ] interface { } ) command . Command = preferencesYaml [ fieldNameCommand ] . ( string ) if argsYaml , ok := preferencesYaml [ fieldNameArgs ] . ( [ ] interface { } ) ; ok { var args [ ] string for _ , arg := range argsYaml { args = append ( args , arg . ( string ) ) } command . Args = args } if path , ok := preferencesYaml [ fieldNamePath ] . ( string ) ; ok { command . Path = path } else { command . Path = " " } if silent , ok := preferencesYaml [ fieldNameSilent ] . ( bool ) ; ok { command . Silent = silent } else { silent = false } return nil }
FromConfig creates a command struct from the given config
FromConfig creates a command struct from the given config
// Extract the "Args" field if the exist // Extract "Path" field // Extract "Silent" field