mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-04-08 18:03:37 +00:00
upd generate help script
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
@@ -12,20 +13,25 @@ func main() {
|
|||||||
cmd string
|
cmd string
|
||||||
out string
|
out string
|
||||||
}{
|
}{
|
||||||
{"../cmd/xair-cli/", "xair-help.md"},
|
{"./cmd/xair-cli/", "xair-help.md"},
|
||||||
{"../cmd/x32-cli/", "x32-help.md"},
|
{"./cmd/x32-cli/", "x32-help.md"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cli := range clis {
|
for _, cli := range clis {
|
||||||
helpCmd := exec.Command("go", "run", cli.cmd, "--help")
|
cmdArgs := []string{"run", cli.cmd, "--help"}
|
||||||
|
helpCmd := exec.Command("go", cmdArgs...)
|
||||||
|
helpCmd.Dir = ".."
|
||||||
out, err := helpCmd.Output()
|
out, err := helpCmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap output in markdown console code block
|
// Wrap output in markdown console code block
|
||||||
wrapped := append([]byte("```console\n"), out...)
|
wrapped := append([]byte("```console\n"), out...)
|
||||||
wrapped = append(wrapped, []byte("\n```\n")...)
|
wrapped = append(wrapped, []byte("\n```\n")...)
|
||||||
os.WriteFile(cli.out, wrapped, 0o644)
|
|
||||||
|
if err := os.WriteFile(cli.out, wrapped, 0o644); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user