// Run will run executable scripts described in the summon.config.yaml file
// of the data repository module.
Run will run executable scripts described in the summon.config.yaml file
of the data repository module.
// Run will run executable scripts described in the summon . config . yaml file // of the data repository module .
func (d *Driver) Run(opts ...Option) error {
	err := d.Configure(opts...)
	if err != nil {
		return err
	}
	eu, err := d.findExecutor(d.opts.ref)
	if err != nil {
		return err
	}
	data := d.opts.data
	if data == nil {
		data = map[string]interface{}{}
	}
	data["osArgs"] = os.Args
	invOpts, err := d.renderTemplate(eu.invOpts, data)
	if err != nil {
		return err
	}
	targets := make([]string, 0, len(eu.targets))
	var renderedTargets []string
	for _, t := range FlattenStrings(eu.targets) {
		rt, err := d.renderTemplate(t, data)
		if err != nil {
			return err
		}
		renderedTargets = []string{rt}
		if strings.HasPrefix(rt, "[") && strings.HasSuffix(rt, "]") {
			renderedTargets, err = shlex.Split(strings.Trim(rt, "[]"))
			if err != nil {
				return err
			}
		}
		targets = append(targets, renderedTargets...)
	}
	rargs, err := shlex.Split(invOpts)
	if err != nil {
		return err
	}
	rargs = append(rargs, targets...)
	unusedArgs := computeUnused(d.opts.args, d.opts.argsConsumed)
	rargs = append(rargs, unusedArgs...)
	cmd := d.execCommand(eu.invoker, rargs...)
	if d.opts.debug || d.opts.dryrun {
		msg := "Executing"
		if d.opts.dryrun {
			msg = "Would execute"
		}
		fmt.Fprintf(os.Stderr, "%s `%s`...\n", msg, cmd)
	}
	if !d.opts.dryrun {
		cmd.Stdin = os.Stdin
		cmd.Stdout = os.Stdout
		cmd.Stderr = os.Stderr
		return cmd.Run()
	}
	return nil
}
func ( d * Driver ) Run ( opts ... Option ) error { err := d . Configure ( opts ... ) if err != nil { return err } eu , err := d . findExecutor ( d . opts . ref ) if err != nil { return err } data := d . opts . data if data == nil { data = map [ string ] interface { } { } } data [ " " ] = os . Args invOpts , err := d . renderTemplate ( eu . invOpts , data ) if err != nil { return err } targets := make ( [ ] string , 0 , len ( eu . targets ) ) var renderedTargets [ ] string for _ , t := range FlattenStrings ( eu . targets ) { rt , err := d . renderTemplate ( t , data ) if err != nil { return err } renderedTargets = [ ] string { rt } if strings . HasPrefix ( rt , " " ) && strings . HasSuffix ( rt , " " ) { renderedTargets , err = shlex . Split ( strings . Trim ( rt , " " ) ) if err != nil { return err } } targets = append ( targets , renderedTargets ... ) } rargs , err := shlex . Split ( invOpts ) if err != nil { return err } rargs = append ( rargs , targets ... ) unusedArgs := computeUnused ( d . opts . args , d . opts . argsConsumed ) rargs = append ( rargs , unusedArgs ... ) cmd := d . execCommand ( eu . invoker , rargs ... ) if d . opts . debug || d . opts . dryrun { msg := " " if d . opts . dryrun { msg = " " } fmt . Fprintf ( os . Stderr , " \n " , msg , cmd ) } if ! d . opts . dryrun { cmd . Stdin = os . Stdin cmd . Stdout = os . Stdout cmd . Stderr = os . Stderr return cmd . Run ( ) } return nil }
Run will run executable scripts described in the summon.config.yaml file
of the data repository module.
Run will run executable scripts described in the summon . config . yaml file of the data repository module .
// add arguments // Convert array to real array and merge