|
1 | 1 | package payload |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "encoding/json" |
4 | 5 | "fmt" |
5 | 6 | "strings" |
6 | 7 | "testing" |
@@ -181,12 +182,18 @@ var ( |
181 | 182 |
|
182 | 183 | // String representation of the supported payload types. |
183 | 184 | func (s Supported) String() string { |
184 | | - a := []string{} |
185 | | - for effect := range s.Effects { |
186 | | - a = append(a, fmt.Sprintf("(%s: %s)", effect.String(), strings.Join(s.Effects[effect], ", "))) |
| 185 | + tostr := map[string][]string{} |
| 186 | + for effect, details := range s.Effects { |
| 187 | + tostr[effect.String()] = details |
187 | 188 | } |
| 189 | + a, err := json.Marshal(tostr) |
| 190 | + if err != nil { |
| 191 | + output.PrintfFrameworkError("Could not marshal payload effects: %s", err.Error()) |
188 | 192 |
|
189 | | - return fmt.Sprintf("%s (%s): Effects - %s", s.Type.String(), s.Arch.String(), strings.Join(a, ", ")) |
| 193 | + return "" |
| 194 | + } |
| 195 | + |
| 196 | + return fmt.Sprintf("%s (%s) - Effects: %s", s.Type.String(), s.Arch.String(), a) |
190 | 197 | } |
191 | 198 |
|
192 | 199 | // String representation of the payload supported architecture. |
@@ -447,14 +454,9 @@ func (e Effect) String() string { |
447 | 454 | return "Unknown" |
448 | 455 | case maxKey: |
449 | 456 | return "Unknown" |
450 | | - } |
| 457 | + default: |
| 458 | + output.PrintFrameworkError("Effect is not recognized.") |
451 | 459 |
|
452 | | - var n []string |
453 | | - for key := FileCreate; key < maxKey; key <<= 1 { |
454 | | - if e&key != 0 { |
455 | | - n = append(n, e.String()) |
456 | | - } |
| 460 | + return "" |
457 | 461 | } |
458 | | - |
459 | | - return strings.Join(n, "|") |
460 | 462 | } |
0 commit comments