Skip to content

Commit

Permalink
Added doas completer
Browse files Browse the repository at this point in the history
  • Loading branch information
aftix committed Apr 2, 2024
1 parent 6213be7 commit 4d6ab56
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
39 changes: 39 additions & 0 deletions completers/doas_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/os"
"github.com/carapace-sh/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "doas",
Short: "execute a command as another user",
Long: "https://man.openbsd.org/doas",
Run: func(cmd *cobra.Command, args []string) {},
}

func Execute() error {
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()
rootCmd.Flags().SetInterspersed(false)

rootCmd.Flags().BoolS("clear", "L", false, "Clear any persisted authentications and exit")
rootCmd.Flags().StringS("config", "C", "", "Parse and check configuration file, do not execute command")
rootCmd.Flags().BoolS("shell", "s", false, "Execute shell from $SHELL or /etc/passwd")
rootCmd.Flags().BoolS("silent", "n", false, "Non interactive mode, fail if password entry is needed")
rootCmd.Flags().StringS("user", "u", "root", "Execute command as specified user")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"config": carapace.ActionFiles(),
"user": os.ActionUsers(),
})

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

import "github.com/carapace-sh/carapace-bin/completers/doas_completer/cmd"

func main() {
cmd.Execute()
}

0 comments on commit 4d6ab56

Please sign in to comment.