1
0
Fork 0
mirror of https://github.com/imjasonh/gcloud-help synced 2026-07-06 17:52:24 +00:00
gcloud-help/main.go
Jason Hall 1799759190
Fix crawl workflow failures
- Update GitHub Actions to latest versions (checkout@v4, setup-go@v5, setup-gcloud@v2)
- Use stable Go version from go.mod
- Fix broken pipe error by consuming all gcloud output in main.go

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-13 21:11:28 -04:00

68 lines
1.2 KiB
Go

package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"strings"
"github.com/acarl005/stripansi"
)
var print = flag.String("print", "", "what type of thing to print (groups, commands)")
func main() {
flag.Parse()
b := bufio.NewScanner(os.Stdin)
var groups, commands []string
var ingroups, incommands bool
for b.Scan() {
txt := stripansi.Strip(b.Text())
if strings.HasPrefix(txt, " ") {
continue
}
txt = strings.TrimSpace(txt)
if strings.Contains(txt, "GROUPS") {
ingroups = true
incommands = false
continue
}
if strings.Contains(txt, "COMMANDS") {
ingroups = false
incommands = true
continue
}
if strings.Contains(txt, "NOTES") ||
strings.Contains(txt, "AVAILABLE") ||
strings.Contains(txt, "BACKGROUND") {
ingroups = false
incommands = false
continue
}
if strings.Contains(txt, " ") {
continue
}
if txt == "" {
continue
}
if ingroups {
groups = append(groups, strings.TrimSpace(txt))
}
if incommands {
commands = append(commands, strings.TrimSpace(txt))
}
}
if err := b.Err(); err != nil {
log.Fatal(err)
}
switch *print {
case "groups":
fmt.Println(strings.Join(groups, " "))
case "commands":
fmt.Println(strings.Join(commands, " "))
}
}