Exemple #1
0
func PrepareCommandForRecipe(properties props.PropertiesMap, recipe string, removeUnsetProperties bool, echoCommandLine bool, echoOutput bool, logger i18n.Logger) (*exec.Cmd, error) {
	pattern := properties[recipe]
	if pattern == constants.EMPTY_STRING {
		return nil, i18n.ErrorfWithLogger(logger, constants.MSG_PATTERN_MISSING, recipe)
	}

	var err error
	commandLine := properties.ExpandPropsInString(pattern)
	if removeUnsetProperties {
		commandLine, err = props.DeleteUnexpandedPropsFromString(commandLine)
		if err != nil {
			return nil, i18n.WrapError(err)
		}
	}

	command, err := utils.PrepareCommand(commandLine, logger)
	if err != nil {
		return nil, i18n.WrapError(err)
	}

	if echoCommandLine {
		fmt.Println(commandLine)
	}

	return command, nil
}