1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

fix: CLI_ARGS is a string and not an array (#2191)

This commit is contained in:
Valentin Maerten
2025-04-21 21:31:18 +02:00
committed by GitHub
parent bf4e7960cb
commit 39706105e1
2 changed files with 5 additions and 5 deletions

View File

@@ -13,24 +13,24 @@ import (
// Get fetches the remaining arguments after CLI parsing and splits them into
// two groups: the arguments before the double dash (--) and the arguments after
// the double dash.
func Get() ([]string, []string, error) {
func Get() ([]string, string, error) {
args := pflag.Args()
doubleDashPos := pflag.CommandLine.ArgsLenAtDash()
if doubleDashPos == -1 {
return args, nil, nil
return args, "", nil
}
var quotedCliArgs []string
for _, arg := range args[doubleDashPos:] {
quotedCliArg, err := syntax.Quote(arg, syntax.LangBash)
if err != nil {
return nil, nil, err
return nil, "", err
}
quotedCliArgs = append(quotedCliArgs, quotedCliArg)
}
return args[:doubleDashPos], quotedCliArgs, nil
return args[:doubleDashPos], strings.Join(quotedCliArgs, " "), nil
}
// Parse parses command line argument: tasks and global variables

View File

@@ -76,7 +76,7 @@ func run() error {
if err != nil {
return err
}
_, args, err := args.Get()
args, _, err := args.Get()
if err != nil {
return err
}