Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix genTargetCmd function to deal with multiple and single selections #32

Merged
merged 3 commits into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,24 @@ func slice2String(slice []string) string {
}

func genTargetCmd(cmd *cobra.Command, action, target string) bytes.Buffer {
var buf bytes.Buffer
executable, _ := cmd.Flags().GetString("executable")
buf.WriteString(executable + " " + action + " -target=" + target)
p, _ := cmd.Flags().GetInt("parallel")
buf.WriteString(fmt.Sprintf(" --parallelism=%d", p))
return buf
var buf bytes.Buffer
executable, _ := cmd.Flags().GetString("executable")
buf.WriteString(executable + " " + action)
target = strings.TrimSpace(target)
if strings.HasPrefix(target, "{") && strings.HasSuffix(target, "}") {
// Handle matrix of targets
target = strings.Trim(target, "{}") // Remove surrounding braces
targetList := strings.Split(target, ",")
for _, t := range targetList {
buf.WriteString(" -target=" + strings.TrimSpace(t))
}
} else {
// Handle single target
buf.WriteString(" -target=" + target)
}
p, _ := cmd.Flags().GetInt("parallel")
buf.WriteString(fmt.Sprintf(" --parallelism=%d", p))
return buf
}

func isYes(reader *bufio.Reader) bool {
Expand Down