mirror of
https://github.com/containers/podman.git
synced 2025-06-25 12:20:42 +08:00
Merge pull request #2580 from rhatdan/cleanup1
More cleanup for failures on missing commands.
This commit is contained in:
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -14,6 +13,7 @@ import (
|
|||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
"github.com/fatih/camelcase"
|
"github.com/fatih/camelcase"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -67,6 +67,16 @@ func noSubArgs(c *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func commandRunE() func(*cobra.Command, []string) error {
|
||||||
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) > 0 {
|
||||||
|
return errors.Errorf("unrecognized command `%s %s`\nTry '%s --help' for more information.", cmd.CommandPath(), args[0], cmd.CommandPath())
|
||||||
|
} else {
|
||||||
|
return errors.Errorf("missing command '%s COMMAND'\nTry '%s --help' for more information.", cmd.CommandPath(), cmd.CommandPath())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// getAllOrLatestContainers tries to return the correct list of containers
|
// getAllOrLatestContainers tries to return the correct list of containers
|
||||||
// depending if --all, --latest or <container-id> is used.
|
// depending if --all, --latest or <container-id> is used.
|
||||||
// It requires the Context (c) and the Runtime (runtime). As different
|
// It requires the Context (c) and the Runtime (runtime). As different
|
||||||
@ -537,7 +547,7 @@ Description:
|
|||||||
// This blocks the desplaying of the global options. The main podman
|
// This blocks the desplaying of the global options. The main podman
|
||||||
// command should not use this.
|
// command should not use this.
|
||||||
func UsageTemplate() string {
|
func UsageTemplate() string {
|
||||||
return `Usage:{{if .Runnable}}
|
return `Usage:{{if (and .Runnable (not .HasAvailableSubCommands))}}
|
||||||
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
|
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
|
||||||
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
|
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ var (
|
|||||||
Short: "Manage Containers",
|
Short: "Manage Containers",
|
||||||
Long: containerDescription,
|
Long: containerDescription,
|
||||||
TraverseChildren: true,
|
TraverseChildren: true,
|
||||||
|
RunE: commandRunE(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ var (
|
|||||||
Use: "generate",
|
Use: "generate",
|
||||||
Short: "Generated structured data",
|
Short: "Generated structured data",
|
||||||
Long: generateDescription,
|
Long: generateDescription,
|
||||||
|
RunE: commandRunE(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ var healthcheckCommand = cliconfig.PodmanCommand{
|
|||||||
Use: "healthcheck",
|
Use: "healthcheck",
|
||||||
Short: "Manage Healthcheck",
|
Short: "Manage Healthcheck",
|
||||||
Long: healthcheckDescription,
|
Long: healthcheckDescription,
|
||||||
|
RunE: commandRunE(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ var (
|
|||||||
Use: "image",
|
Use: "image",
|
||||||
Short: "Manage images",
|
Short: "Manage images",
|
||||||
Long: imageDescription,
|
Long: imageDescription,
|
||||||
|
RunE: commandRunE(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
imagesSubCommand cliconfig.ImagesValues
|
imagesSubCommand cliconfig.ImagesValues
|
||||||
|
@ -82,9 +82,7 @@ var cmdsNotRequiringRootless = map[*cobra.Command]bool{
|
|||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "podman",
|
Use: "podman",
|
||||||
Long: "manage pods and images",
|
Long: "manage pods and images",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: commandRunE(),
|
||||||
return cmd.Help()
|
|
||||||
},
|
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return before(cmd, args)
|
return before(cmd, args)
|
||||||
},
|
},
|
||||||
|
@ -12,6 +12,7 @@ var (
|
|||||||
Use: "play",
|
Use: "play",
|
||||||
Short: "Play a pod",
|
Short: "Play a pod",
|
||||||
Long: playDescription,
|
Long: playDescription,
|
||||||
|
RunE: commandRunE(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ var podCommand = cliconfig.PodmanCommand{
|
|||||||
Use: "pod",
|
Use: "pod",
|
||||||
Short: "Manage pods",
|
Short: "Manage pods",
|
||||||
Long: podDescription,
|
Long: podDescription,
|
||||||
|
RunE: commandRunE(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ var (
|
|||||||
Use: "system",
|
Use: "system",
|
||||||
Short: "Manage podman",
|
Short: "Manage podman",
|
||||||
Long: systemDescription,
|
Long: systemDescription,
|
||||||
|
RunE: commandRunE(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -14,6 +14,7 @@ var (
|
|||||||
Use: "trust",
|
Use: "trust",
|
||||||
Short: "Manage container image trust policy",
|
Short: "Manage container image trust policy",
|
||||||
Long: trustDescription,
|
Long: trustDescription,
|
||||||
|
RunE: commandRunE(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -12,6 +12,7 @@ var volumeCommand = cliconfig.PodmanCommand{
|
|||||||
Use: "volume",
|
Use: "volume",
|
||||||
Short: "Manage volumes",
|
Short: "Manage volumes",
|
||||||
Long: volumeDescription,
|
Long: volumeDescription,
|
||||||
|
RunE: commandRunE(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var volumeSubcommands = []*cobra.Command{
|
var volumeSubcommands = []*cobra.Command{
|
||||||
|
Reference in New Issue
Block a user