mirror of
https://github.com/imjasonh/gcloud-help
synced 2026-07-19 07:15:23 +00:00
initial commit
This commit is contained in:
commit
632280c428
5 changed files with 122 additions and 0 deletions
30
.github/workflows/crawl.yaml
vendored
Normal file
30
.github/workflows/crawl.yaml
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
name: crawl
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches: ['main']
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
crawl:
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.17.x
|
||||||
|
- uses: google-github-actions/setup-gcloud@v0
|
||||||
|
with:
|
||||||
|
install_components: alpha,beta
|
||||||
|
|
||||||
|
run: crawl.sh
|
||||||
|
run: |
|
||||||
|
git config user.name "Automated"
|
||||||
|
git config user.email "actions@users.noreply.github.com"
|
||||||
|
git add -A
|
||||||
|
timestamp=$(date -u)
|
||||||
|
git commit -m "gcloud: ${timestamp}" || exit 0
|
||||||
|
git push
|
||||||
|
|
||||||
21
crawl.sh
Executable file
21
crawl.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
path=$(pwd)/$(printf "%s/" "$@")
|
||||||
|
mkdir -p $path
|
||||||
|
|
||||||
|
groups=$(gcloud help $@ | go run ./ -print=groups)
|
||||||
|
commands=$(gcloud help $@ | go run ./ -print=commands)
|
||||||
|
|
||||||
|
gcloud help > help
|
||||||
|
|
||||||
|
for grp in $groups; do
|
||||||
|
mkdir -p $path/$grp
|
||||||
|
gcloud help $@ $grp > $path/$grp/help
|
||||||
|
./crawl.sh $@ $grp
|
||||||
|
done
|
||||||
|
|
||||||
|
for cmd in $commands; do
|
||||||
|
gcloud help $@ $cmd > $path/$cmd
|
||||||
|
done
|
||||||
5
go.mod
Normal file
5
go.mod
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
module github.com/imjasonh/gcloud-help
|
||||||
|
|
||||||
|
go 1.17
|
||||||
|
|
||||||
|
require github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
|
||||||
2
go.sum
Normal file
2
go.sum
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
|
||||||
|
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
|
||||||
64
main.go
Normal file
64
main.go
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
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") {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
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, " "))
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue