Skip to content

Commit

Permalink
added gh-copilot
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Feb 18, 2024
1 parent 3ee6a55 commit a0a292e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
19 changes: 19 additions & 0 deletions completers/gh-copilot_completer/cmd/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

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

var configCmd = &cobra.Command{
Use: "config",
Short: "Change configuration options, such as sending of optional analytics data",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(configCmd).Standalone()

configCmd.Flags().BoolP("help", "h", false, "help for config")
rootCmd.AddCommand(configCmd)
}
24 changes: 24 additions & 0 deletions completers/gh-copilot_completer/cmd/explain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

var explainCmd = &cobra.Command{
Use: "explain",
Short: "Explain a given input command in natural language",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(explainCmd).Standalone()

explainCmd.Flags().BoolP("help", "h", false, "help for explain")
rootCmd.AddCommand(explainCmd)

carapace.Gen(explainCmd).PositionalCompletion(
bridge.ActionCarapaceBin().SplitP(),
)
}
22 changes: 22 additions & 0 deletions completers/gh-copilot_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

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

var rootCmd = &cobra.Command{
Use: "gh-copilot",
Short: "Your AI command line copilot",
Run: func(cmd *cobra.Command, args []string) {},
}

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

rootCmd.Flags().BoolP("help", "h", false, "help for copilot")
rootCmd.Flags().BoolP("version", "v", false, "version for copilot")
}
24 changes: 24 additions & 0 deletions completers/gh-copilot_completer/cmd/suggest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

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

var suggestCmd = &cobra.Command{
Use: "suggest",
Short: "Suggest a command based on a natural language description of the desired output effect",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(suggestCmd).Standalone()

suggestCmd.Flags().BoolP("help", "h", false, "help for suggest")
suggestCmd.Flags().StringP("target", "t", "", "Target for suggestion; must be shell, gh, git")
rootCmd.AddCommand(suggestCmd)

carapace.Gen(suggestCmd).FlagCompletion(carapace.ActionMap{
"target": carapace.ActionValues("shell", "gh", "git"),
})
}
7 changes: 7 additions & 0 deletions completers/gh-copilot_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/gh-copilot_completer/cmd"

func main() {
cmd.Execute()
}

0 comments on commit a0a292e

Please sign in to comment.