parseInstalledVersionOutput scans the output of `gh aw version` for the first token that is a valid semantic version (with or without a leading "v"). It returns the version normalized to include a "v" prefix.
(output string)
| 536 | // first token that is a valid semantic version (with or without a leading "v"). |
| 537 | // It returns the version normalized to include a "v" prefix. |
| 538 | func parseInstalledVersionOutput(output string) (string, error) { |
| 539 | for token := range strings.FieldsSeq(output) { |
| 540 | if semverutil.IsValid(token) { |
| 541 | return semverutil.EnsureVPrefix(token), nil |
| 542 | } |
| 543 | } |
| 544 | return "", fmt.Errorf("could not parse installed gh-aw version from output: %s", summarizeCommandOutput(output)) |
| 545 | } |
| 546 | |
| 547 | func summarizeCommandOutput(output string) string { |
| 548 | const maxOutputLen = 300 |