Skip to content

Commit 06cda88

Browse files
committed
Add autocomplete commands
Signed-off-by: Tyler Rockwood <[email protected]>
1 parent 3a32210 commit 06cda88

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

main.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,24 @@ func getListOfPackages(pkgs []string, options *compileopts.Options) ([]string, e
13861386
return pkgNames, nil
13871387
}
13881388

1389+
func printAutocompleteHelp() {
1390+
type pluginHelp struct {
1391+
Path string `json:"path,omitempty"`
1392+
Short string `json:"short,omitempty"`
1393+
Long string `json:"long,omitempty"`
1394+
Example string `json:"example,omitempty"`
1395+
Args []string `json:"args,omitempty"`
1396+
}
1397+
buildHelp := pluginHelp{
1398+
Path: "transform_build_tinygo",
1399+
Short: "compile a tinygo module in the current directory",
1400+
}
1401+
b, err := json.Marshal(&[]pluginHelp{buildHelp})
1402+
if err != nil {
1403+
}
1404+
fmt.Fprintln(os.Stdout, string(b))
1405+
}
1406+
13891407
// This is a pure addition to upstream tinygo.
13901408
//
13911409
// It provides a hardcoded `build` command and autocomplete support for rpk
@@ -1432,8 +1450,15 @@ func main() {
14321450
llvmFeatures := flag.String("llvm-features", "", "comma separated LLVM features to enable")
14331451
flagJSON := flag.Bool("json", false, "print data in JSON format")
14341452
outpath := flag.String("o", "", "output filename")
1453+
helpAutocomplete := flag.Bool("help-autocomplete", false, "output complete help for rpk")
14351454
// strip the .rpk.managed-tinygo prefix
14361455
flag.CommandLine.Parse(os.Args[1:])
1456+
1457+
if *helpAutocomplete {
1458+
printAutocompleteHelp()
1459+
os.Exit(0)
1460+
}
1461+
14371462
globalVarValues, err := parseGoLinkFlag(*ldflags)
14381463
if err != nil {
14391464
fmt.Fprintln(os.Stderr, err)

0 commit comments

Comments
 (0)