Skip to content

Commit

Permalink
Showing 2 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions completers/python_completer/cmd/module/httpServer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package module

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

func ExecuteHttpServer() error {
cmd := &cobra.Command{
Use: "http.server",
Short: "simple http server",
Run: func(cmd *cobra.Command, args []string) {},
}

carapace.Gen(cmd).Standalone()

cmd.Flags().StringP("bind", "b", "", "Specify alternate bind address")
cmd.Flags().Bool("cgi", false, "Run as CGI Server")
cmd.Flags().StringP("directory", "d", "", "Specify alternative directory")
cmd.Flags().BoolP("help", "h", false, "show this help message and exit")

carapace.Gen(cmd).FlagCompletion(carapace.ActionMap{
"directory": carapace.ActionDirectories(),
})

carapace.Gen(cmd).PositionalCompletion(
net.ActionPorts(),
)

return cmd.Execute()
}
2 changes: 2 additions & 0 deletions completers/python_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -95,6 +95,8 @@ func init() {
carapace.Gen(rootCmd).DashAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
switch rootCmd.Flag("m").Value.String() {
case "http.server":
return carapace.ActionInvoke(module.ExecuteHttpServer)
case "venv":
return carapace.ActionInvoke(module.ExecuteVenv)
default:

0 comments on commit a8fd8ec

Please sign in to comment.