Skip to content

Commit

Permalink
added capslock
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 19, 2023
1 parent 9eded0f commit 3fcace4
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 3fcace4

Please sign in to comment.