Skip to content

Commit

Permalink
Merge pull request #1844 from rsteube/add-capslock
Browse files Browse the repository at this point in the history
added capslock
  • Loading branch information
rsteube authored Sep 19, 2023
2 parents b822349 + 3fcace4 commit 68f874a
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
36 changes: 36 additions & 0 deletions completers/capslock_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/golang"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "capslock",
Short: "Capslock is a capability analysis CLI for Go packages ",
Long: "https://github.com/google/capslock",
Run: func(cmd *cobra.Command, args []string) {},
}

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

rootCmd.Flags().StringS("buildtags", "buildtags", "", "command-separated list of build tags to use when loading packages")
rootCmd.Flags().StringS("goarch", "goarch", "", "GOARCH value to use when loading packages")
rootCmd.Flags().StringS("goos", "goos", "", "GOOS value to use when loading packages")
rootCmd.Flags().BoolS("noisy", "noisy", false, "include output on unanalyzed function calls")
rootCmd.Flags().StringS("output", "output", "", "output mode to use")
rootCmd.Flags().StringS("packages", "packages", "", "target patterns to be analysed")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"buildtags": golang.ActionBuildTags(),
"goarch": golang.ActionArchitectures(),
"goos": golang.ActionOperatingSystems(),
"output": carapace.ActionValues("json", "m", "v", "graph", "compare"),
"packages": golang.ActionPackages(),
})
}
7 changes: 7 additions & 0 deletions completers/capslock_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/capslock_completer/cmd"

func main() {
cmd.Execute()
}
84 changes: 84 additions & 0 deletions pkg/actions/tools/golang/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package golang

import "github.com/rsteube/carapace"

// ActionOperatingSystems completes known operating systems
//
// aix
// android
func ActionOperatingSystems() carapace.Action {
return carapace.ActionValues(
"aix",
"android",
"darwin",
"dragonfly",
"freebsd",
"hurd",
"illumos",
"ios",
"js",
"linux",
"nacl",
"netbsd",
"openbsd",
"plan9",
"solaris",
"wasip1",
"windows",
"zos",
)
}

// ActionUnixOperatingSystems completes known operating systems matched by the "unix" build tag
//
// darwin
// linux
func ActionUnixOperatingSystems() carapace.Action {
return carapace.ActionValues(
"aix",
"android",
"darwin",
"dragonfly",
"freebsd",
"hurd",
"illumos",
"ios",
"linux",
"netbsd",
"openbsd",
"solaris",
)
}

// ActionArchitectures completes known architectures
//
// 386
// amd64
func ActionArchitectures() carapace.Action {
return carapace.ActionValues(
"386",
"amd64",
"amd64p32",
"arm",
"armbe",
"arm64",
"arm64be",
"loong64",
"mips",
"mipsle",
"mips64",
"mips64le",
"mips64p32",
"mips64p32le",
"ppc",
"ppc64",
"ppc64le",
"riscv",
"riscv64",
"s390",
"s390x",
"sparc",
"sparc64",
"wasm",
)
}

0 comments on commit 68f874a

Please sign in to comment.