Skip to content

Commit

Permalink
Merge pull request #933 from rsteube/python-httpserver-module
Browse files Browse the repository at this point in the history
python: added http.server module
  • Loading branch information
rsteube authored Feb 16, 2022
2 parents 7eeea48 + a8fd8ec commit ab32b19
Show file tree
Hide file tree
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
Expand Up @@ -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:
Expand Down

0 comments on commit ab32b19

Please sign in to comment.