Skip to content

Commit

Permalink
Merge pull request #32 from jmonfar/fix-multitarget
Browse files Browse the repository at this point in the history
Fix genTargetCmd function to deal with multiple and single selections
  • Loading branch information
orangekame3 authored Dec 24, 2024
2 parents 1eeeffa + 9945cd3 commit dc778a5
Showing 1 changed file with 18 additions and 6 deletions.
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

0 comments on commit dc778a5

Please sign in to comment.