Skip to content

Commit

Permalink
added docker subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 6, 2020
1 parent 4305f9b commit 38023e3
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 4 deletions.
23 changes: 23 additions & 0 deletions completers/docker_completer/cmd/inspect.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package cmd

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

var inspectCmd = &cobra.Command{
Use: "inspect",
Short: "Return low-level information on Docker objects",
Run: func(cmd *cobra.Command, args []string) {},
}

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

inspectCmd.Flags().StringP("format", "f", "", "Format the output using the given Go template")
inspectCmd.Flags().BoolP("size", "s", false, "Display total file sizes if the type is container")
inspectCmd.Flags().String("type", "", "Return JSON for specified type")
rootCmd.AddCommand(inspectCmd)

// TODO complete positiona parameters
}
21 changes: 21 additions & 0 deletions completers/docker_completer/cmd/login.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cmd

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

var loginCmd = &cobra.Command{
Use: "login",
Short: "Log in to a Docker registry",
Run: func(cmd *cobra.Command, args []string) {},
}

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

loginCmd.Flags().StringP("password", "p", "", "Password")
loginCmd.Flags().Bool("password-stdin", false, "Take the password from stdin")
loginCmd.Flags().StringP("username", "u", "", "Username")
rootCmd.AddCommand(loginCmd)
}
18 changes: 18 additions & 0 deletions completers/docker_completer/cmd/logout.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

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

var logoutCmd = &cobra.Command{
Use: "logout",
Short: "Log out from a Docker registry",
Run: func(cmd *cobra.Command, args []string) {},
}

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

rootCmd.AddCommand(logoutCmd)
}
7 changes: 3 additions & 4 deletions completers/docker_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ func init() {
rootCmd.AddCommand(container_execCmd)
rootCmd.AddCommand(container_exportCmd)
rootCmd.AddCommand(image_historyCmd)
imagesCmd := image_lsCmd
imagesCmd.Use = "images"
rootCmd.AddCommand(imagesCmd)
rootCmd.AddCommand(image_importCmd)
rootCmd.AddCommand(system_infoCmd)
// TODO docker inspect command
rootCmd.AddCommand(container_killCmd)
rootCmd.AddCommand(image_loadCmd)
// TODO docker login command
// TODO docker logout command
rootCmd.AddCommand(container_logsCmd)
rootCmd.AddCommand(container_pauseCmd)
rootCmd.AddCommand(container_portCmd)
Expand All @@ -70,7 +70,6 @@ func init() {
rootCmd.AddCommand(rmiCmd)
rootCmd.AddCommand(container_runCmd)
rootCmd.AddCommand(image_saveCmd)
// TODO docker search command
rootCmd.AddCommand(container_startCmd)
rootCmd.AddCommand(container_statsCmd)
rootCmd.AddCommand(container_stopCmd)
Expand Down
22 changes: 22 additions & 0 deletions completers/docker_completer/cmd/search.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 searchCmd = &cobra.Command{
Use: "search",
Short: "Search the Docker Hub for images",
Run: func(cmd *cobra.Command, args []string) {},
}

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

searchCmd.Flags().StringP("filter", "f", "", "Filter output based on conditions provided")
searchCmd.Flags().String("format", "", "Pretty-print search using a Go template")
searchCmd.Flags().String("limit", "", "Max number of search results (default 25)")
searchCmd.Flags().Bool("no-trunc", false, "Don't truncate output")
rootCmd.AddCommand(searchCmd)
}
20 changes: 20 additions & 0 deletions completers/docker_completer/cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cmd

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

var versionCmd = &cobra.Command{
Use: "version",
Short: "Show the Docker version information",
Run: func(cmd *cobra.Command, args []string) {},
}

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

versionCmd.Flags().StringP("format", "f", "", "Format the output using the given Go template")
versionCmd.Flags().String("kubeconfig", "", "Kubernetes config file")
rootCmd.AddCommand(versionCmd)
}

0 comments on commit 38023e3

Please sign in to comment.