// Args renders the command arguments using the provided template data and options.
Args renders the command arguments using the provided template data and options.
// Args renders the command arguments using the provided template data and options .
func (c Command) Args(data TemplateData, options TemplateOptions) ([]string, error) {
	if len(c.Command) <= 1 {
		return []string{}, nil
	}
	args := make([]string, len(c.Command)-1)
	copy(args, c.Command[1:])
	for i, raw := range args {
		tpl, err := template.New(c.ID).Option("missingkey=error").Funcs(template.FuncMap{
			"trim":      strings.TrimSpace,
			"json":      gjson.Get,
			"sensitive": sensitiveFunc(options.ShowSensitive),
		}).Parse(raw)
		if err != nil {
			return nil, err
		}
		o := new(bytes.Buffer)
		if err := tpl.Execute(o, data); err != nil {
			return nil, err
		}
		args[i] = o.String()
	}
	return args, nil
}
func ( c Command ) Args ( data TemplateData , options TemplateOptions ) ( [ ] string , error ) { if len ( c . Command ) <= 1 { return [ ] string { } , nil } args := make ( [ ] string , len ( c . Command ) - 1 ) copy ( args , c . Command [ 1 : ] ) for i , raw := range args { tpl , err := template . New ( c . ID ) . Option ( " " ) . Funcs ( template . FuncMap { " " : strings . TrimSpace , " " : gjson . Get , " " : sensitiveFunc ( options . ShowSensitive ) , } ) . Parse ( raw ) if err != nil { return nil , err } o := new ( bytes . Buffer ) if err := tpl . Execute ( o , data ) ; err != nil { return nil , err } args [ i ] = o . String ( ) } return args , nil }
Args renders the command arguments using the provided template data and options.
Args renders the command arguments using the provided template data and options .