Skip to content

Commit

Permalink
added go-tool-asm
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jul 17, 2023
1 parent ce555ac commit d881f67
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
65 changes: 65 additions & 0 deletions completers/go-tool-asm_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "go-tool-asm",
Short: "go assembler",
Long: "https://pkg.go.dev/cmd/asm",
Run: func(cmd *cobra.Command, args []string) {},
}

func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()

rootCmd.Flags().StringSliceS("D", "D", []string{}, "predefined symbol with optional simple value -D=identifier=value")
rootCmd.Flags().StringSliceS("I", "I", []string{}, "include directory")
rootCmd.Flags().BoolS("compiling-runtime", "compiling-runtime", false, "source to be compiled is part of the Go runtime")
rootCmd.Flags().StringS("d", "d", "", "enable debugging settings")
rootCmd.Flags().BoolS("debug", "debug", false, "dump instructions as they are parsed")
rootCmd.Flags().BoolS("dynlink", "dynlink", false, "support references to Go symbols defined in other shared libraries")
rootCmd.Flags().BoolS("gensymabis", "gensymabis", false, "write symbol ABI information to output file, don't assemble")
rootCmd.Flags().BoolS("linkshared", "linkshared", false, "generate code that will be linked against Go shared libraries")
rootCmd.Flags().StringS("o", "o", "", "output file")
rootCmd.Flags().StringS("p", "p", "", "set expected package import to path")
rootCmd.Flags().BoolS("shared", "shared", false, "generate code that can be linked into a shared library")
rootCmd.Flags().StringS("spectre", "spectre", "", "enable spectre mitigations in list")
rootCmd.Flags().StringS("trimpath", "trimpath", "", "remove prefix from recorded source file paths")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"I": carapace.ActionDirectories(),
"d": carapace.ActionMultiParts(",", func(c carapace.Context) carapace.Action {
return carapace.ActionMultiParts("=", func(c carapace.Context) carapace.Action {
switch len(c.Parts) {
case 0:
return carapace.ActionValuesDescribed(
"maymorestack", ",call named function before all stack growth checks",
"pctab", "print named pc-value table",
).Suffix("=")

case 1:
switch c.Parts[0] {
case "pctab":
return carapace.ActionValues("pctospadj", "pctofile", "pctoline", "pctoinline", "pctopcdata").NoSpace()
default:
return carapace.ActionValues()
}

default:
return carapace.ActionValues()
}
})
}),
"o": carapace.ActionFiles(),
})

carapace.Gen(rootCmd).PositionalAnyCompletion(
carapace.ActionFiles(),
)
}
7 changes: 7 additions & 0 deletions completers/go-tool-asm_completer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rsteube/carapace-bin/completers/go-tool-asm_completer/cmd"

func main() {
cmd.Execute()
}

0 comments on commit d881f67

Please sign in to comment.