Merge pull request #2633 from edsantiago/default_default

Usage messages: deduplicate '(default true)' et al
This commit is contained in:
OpenShift Merge Robot 2019-03-15 06:22:46 -07:00 committed by GitHub
commit ccf991f530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 27 additions and 27 deletions

View File

@ -35,7 +35,7 @@ func init() {
flags := attachCommand.Flags() flags := attachCommand.Flags()
flags.StringVar(&attachCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _") flags.StringVar(&attachCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _")
flags.BoolVar(&attachCommand.NoStdin, "no-stdin", false, "Do not attach STDIN. The default is false") flags.BoolVar(&attachCommand.NoStdin, "no-stdin", false, "Do not attach STDIN. The default is false")
flags.BoolVar(&attachCommand.SigProxy, "sig-proxy", true, "Proxy received signals to the process (default true)") flags.BoolVar(&attachCommand.SigProxy, "sig-proxy", true, "Proxy received signals to the process")
flags.BoolVarP(&attachCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of") flags.BoolVarP(&attachCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
markFlagHiddenForRemoteClient("latest", flags) markFlagHiddenForRemoteClient("latest", flags)
} }

View File

@ -313,7 +313,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
) )
createFlags.String( createFlags.String(
"image-volume", "bind", "image-volume", "bind",
"Tells podman how to handle the builtin image volumes. The options are: 'bind', 'tmpfs', or 'ignore' (default 'bind')", "Tells podman how to handle the builtin image volumes. The options are: 'bind', 'tmpfs', or 'ignore'",
) )
createFlags.Bool( createFlags.Bool(
"init", false, "init", false,
@ -374,7 +374,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
) )
createFlags.Int64( createFlags.Int64(
"memory-swappiness", -1, "memory-swappiness", -1,
"Tune container memory swappiness (0 to 100) (default -1)", "Tune container memory swappiness (0 to 100, or -1 for system default)",
) )
createFlags.String( createFlags.String(
"name", "", "name", "",

View File

@ -36,7 +36,7 @@ func init() {
exportCommand.SetHelpTemplate(HelpTemplate()) exportCommand.SetHelpTemplate(HelpTemplate())
exportCommand.SetUsageTemplate(UsageTemplate()) exportCommand.SetUsageTemplate(UsageTemplate())
flags := exportCommand.Flags() flags := exportCommand.Flags()
flags.StringVarP(&exportCommand.Output, "output", "o", "/dev/stdout", "Write to a file, default is STDOUT") flags.StringVarP(&exportCommand.Output, "output", "o", "", "Write to a specified file (default: stdout, which must be redirected)")
} }
// exportCmd saves a container to a tarball on disk // exportCmd saves a container to a tarball on disk
@ -60,15 +60,16 @@ func exportCmd(c *cliconfig.ExportValues) error {
} }
output := c.Output output := c.Output
if runtime.Remote && (output == "/dev/stdout" || len(output) == 0) { if runtime.Remote && len(output) == 0 {
return errors.New("remote client usage must specify an output file (-o)") return errors.New("remote client usage must specify an output file (-o)")
} }
if output == "/dev/stdout" { if len(output) == 0 {
file := os.Stdout file := os.Stdout
if logrus.IsTerminal(file) { if logrus.IsTerminal(file) {
return errors.Errorf("refusing to export to terminal. Use -o flag or redirect") return errors.Errorf("refusing to export to terminal. Use -o flag or redirect")
} }
output = "/dev/stdout"
} }
if err := parse.ValidateFileName(output); err != nil { if err := parse.ValidateFileName(output); err != nil {

View File

@ -34,7 +34,7 @@ func init() {
loadCommand.SetHelpTemplate(HelpTemplate()) loadCommand.SetHelpTemplate(HelpTemplate())
loadCommand.SetUsageTemplate(UsageTemplate()) loadCommand.SetUsageTemplate(UsageTemplate())
flags := loadCommand.Flags() flags := loadCommand.Flags()
flags.StringVarP(&loadCommand.Input, "input", "i", "/dev/stdin", "Read from archive file, default is STDIN") flags.StringVarP(&loadCommand.Input, "input", "i", "", "Read from specified archive file (default: stdin)")
flags.BoolVarP(&loadCommand.Quiet, "quiet", "q", false, "Suppress the output") flags.BoolVarP(&loadCommand.Quiet, "quiet", "q", false, "Suppress the output")
flags.StringVar(&loadCommand.SignaturePolicy, "signature-policy", "", "Pathname of signature policy file (not usually used)") flags.StringVar(&loadCommand.SignaturePolicy, "signature-policy", "", "Pathname of signature policy file (not usually used)")
@ -64,7 +64,10 @@ func loadCmd(c *cliconfig.LoadValues) error {
if runtime.Remote && len(input) == 0 { if runtime.Remote && len(input) == 0 {
return errors.New("the remote client requires you to load via -i and a tarball") return errors.New("the remote client requires you to load via -i and a tarball")
} }
if input == "/dev/stdin" { if len(input) == 0 {
input = "/dev/stdin"
c.Input = input
fi, err := os.Stdin.Stat() fi, err := os.Stdin.Stat()
if err != nil { if err != nil {
return err return err

View File

@ -45,7 +45,7 @@ func init() {
flags.StringVar(&loginCommand.CertDir, "cert-dir", "", "Pathname of a directory containing TLS certificates and keys used to connect to the registry") flags.StringVar(&loginCommand.CertDir, "cert-dir", "", "Pathname of a directory containing TLS certificates and keys used to connect to the registry")
flags.BoolVar(&loginCommand.GetLogin, "get-login", true, "Return the current login user for the registry") flags.BoolVar(&loginCommand.GetLogin, "get-login", true, "Return the current login user for the registry")
flags.StringVarP(&loginCommand.Password, "password", "p", "", "Password for registry") flags.StringVarP(&loginCommand.Password, "password", "p", "", "Password for registry")
flags.BoolVar(&loginCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries (default: true)") flags.BoolVar(&loginCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries")
flags.StringVarP(&loginCommand.Username, "username", "u", "", "Username for registry") flags.StringVarP(&loginCommand.Username, "username", "u", "", "Username for registry")
flags.BoolVar(&loginCommand.StdinPassword, "password-stdin", false, "Take the password from stdin") flags.BoolVar(&loginCommand.StdinPassword, "password-stdin", false, "Take the password from stdin")

View File

@ -115,7 +115,7 @@ func init() {
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.DefaultMountsFile, "default-mounts-file", "", "Path to default mounts file") rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.DefaultMountsFile, "default-mounts-file", "", "Path to default mounts file")
rootCmd.PersistentFlags().MarkHidden("defaults-mount-file") rootCmd.PersistentFlags().MarkHidden("defaults-mount-file")
rootCmd.PersistentFlags().StringSliceVar(&MainGlobalOpts.HooksDir, "hooks-dir", []string{}, "Set the OCI hooks directory path (may be set multiple times)") rootCmd.PersistentFlags().StringSliceVar(&MainGlobalOpts.HooksDir, "hooks-dir", []string{}, "Set the OCI hooks directory path (may be set multiple times)")
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.LogLevel, "log-level", "error", "Log messages above specified level: debug, info, warn, error (default), fatal or panic") rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.LogLevel, "log-level", "error", "Log messages above specified level: debug, info, warn, error, fatal or panic")
rootCmd.PersistentFlags().IntVar(&MainGlobalOpts.MaxWorks, "max-workers", 0, "The maximum number of workers for parallel operations") rootCmd.PersistentFlags().IntVar(&MainGlobalOpts.MaxWorks, "max-workers", 0, "The maximum number of workers for parallel operations")
rootCmd.PersistentFlags().MarkHidden("max-workers") rootCmd.PersistentFlags().MarkHidden("max-workers")
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.Namespace, "namespace", "", "Set the libpod namespace, used to create separate views of the containers and pods on the system") rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.Namespace, "namespace", "", "Set the libpod namespace, used to create separate views of the containers and pods on the system")

View File

@ -59,7 +59,7 @@ func init() {
flags.StringVar(&playKubeCommand.Creds, "creds", "", "`Credentials` (USERNAME:PASSWORD) to use for authenticating to a registry") flags.StringVar(&playKubeCommand.Creds, "creds", "", "`Credentials` (USERNAME:PASSWORD) to use for authenticating to a registry")
flags.BoolVarP(&playKubeCommand.Quiet, "quiet", "q", false, "Suppress output information when pulling images") flags.BoolVarP(&playKubeCommand.Quiet, "quiet", "q", false, "Suppress output information when pulling images")
flags.StringVar(&playKubeCommand.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)") flags.StringVar(&playKubeCommand.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)")
flags.BoolVar(&playKubeCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries (default: true)") flags.BoolVar(&playKubeCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries")
} }
func playKubeYAMLCmd(c *cliconfig.KubePlayValues) error { func playKubeYAMLCmd(c *cliconfig.KubePlayValues) error {

View File

@ -52,7 +52,7 @@ func init() {
flags.StringVar(&pullCommand.Creds, "creds", "", "`Credentials` (USERNAME:PASSWORD) to use for authenticating to a registry") flags.StringVar(&pullCommand.Creds, "creds", "", "`Credentials` (USERNAME:PASSWORD) to use for authenticating to a registry")
flags.BoolVarP(&pullCommand.Quiet, "quiet", "q", false, "Suppress output information when pulling images") flags.BoolVarP(&pullCommand.Quiet, "quiet", "q", false, "Suppress output information when pulling images")
flags.StringVar(&pullCommand.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)") flags.StringVar(&pullCommand.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)")
flags.BoolVar(&pullCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries (default: true)") flags.BoolVar(&pullCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries")
} }

View File

@ -54,7 +54,7 @@ func init() {
flags.BoolVar(&pushCommand.RemoveSignatures, "remove-signatures", false, "Discard any pre-existing signatures in the image") flags.BoolVar(&pushCommand.RemoveSignatures, "remove-signatures", false, "Discard any pre-existing signatures in the image")
flags.StringVar(&pushCommand.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)") flags.StringVar(&pushCommand.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)")
flags.StringVar(&pushCommand.SignBy, "sign-by", "", "Add a signature at the destination using the specified key") flags.StringVar(&pushCommand.SignBy, "sign-by", "", "Add a signature at the destination using the specified key")
flags.BoolVar(&pushCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries (default: true)") flags.BoolVar(&pushCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries")
} }
func pushCmd(c *cliconfig.PushValues) error { func pushCmd(c *cliconfig.PushValues) error {

View File

@ -44,7 +44,7 @@ func init() {
runCommand.SetUsageTemplate(UsageTemplate()) runCommand.SetUsageTemplate(UsageTemplate())
flags := runCommand.Flags() flags := runCommand.Flags()
flags.SetInterspersed(false) flags.SetInterspersed(false)
flags.Bool("sig-proxy", true, "Proxy received signals to the process (default true)") flags.Bool("sig-proxy", true, "Proxy received signals to the process")
getCreateFlags(&runCommand.PodmanCommand) getCreateFlags(&runCommand.PodmanCommand)
} }

View File

@ -57,7 +57,7 @@ func init() {
flags.BoolP("pull", "p", false, "Pull the image if it does not exist locally prior to executing the label contents") flags.BoolP("pull", "p", false, "Pull the image if it does not exist locally prior to executing the label contents")
flags.BoolVarP(&runlabelCommand.Quiet, "quiet", "q", false, "Suppress output information when installing images") flags.BoolVarP(&runlabelCommand.Quiet, "quiet", "q", false, "Suppress output information when installing images")
flags.StringVar(&runlabelCommand.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)") flags.StringVar(&runlabelCommand.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)")
flags.BoolVar(&runlabelCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries (default: true)") flags.BoolVar(&runlabelCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries")
flags.MarkDeprecated("pull", "podman will pull if not found in local storage") flags.MarkDeprecated("pull", "podman will pull if not found in local storage")
} }

View File

@ -58,7 +58,7 @@ func init() {
flags := saveCommand.Flags() flags := saveCommand.Flags()
flags.BoolVar(&saveCommand.Compress, "compress", false, "Compress tarball image layers when saving to a directory using the 'dir' transport. (default is same compression type as source)") flags.BoolVar(&saveCommand.Compress, "compress", false, "Compress tarball image layers when saving to a directory using the 'dir' transport. (default is same compression type as source)")
flags.StringVar(&saveCommand.Format, "format", v2s2Archive, "Save image to oci-archive, oci-dir (directory with oci manifest type), docker-archive, docker-dir (directory with v2s2 manifest type)") flags.StringVar(&saveCommand.Format, "format", v2s2Archive, "Save image to oci-archive, oci-dir (directory with oci manifest type), docker-archive, docker-dir (directory with v2s2 manifest type)")
flags.StringVarP(&saveCommand.Output, "output", "o", "/dev/stdout", "Write to a file, default is STDOUT") flags.StringVarP(&saveCommand.Output, "output", "o", "", "Write to a specified file (default: stdout, which must be redirected)")
flags.BoolVarP(&saveCommand.Quiet, "quiet", "q", false, "Suppress the output") flags.BoolVarP(&saveCommand.Quiet, "quiet", "q", false, "Suppress the output")
} }
@ -79,14 +79,14 @@ func saveCmd(c *cliconfig.SaveValues) error {
return errors.Errorf("--compress can only be set when --format is either 'oci-dir' or 'docker-dir'") return errors.Errorf("--compress can only be set when --format is either 'oci-dir' or 'docker-dir'")
} }
output := c.Output if len(c.Output) == 0 {
if output == "/dev/stdout" {
fi := os.Stdout fi := os.Stdout
if logrus.IsTerminal(fi) { if logrus.IsTerminal(fi) {
return errors.Errorf("refusing to save to terminal. Use -o flag or redirect") return errors.Errorf("refusing to save to terminal. Use -o flag or redirect")
} }
c.Output = "/dev/stdout"
} }
if err := parse.ValidateFileName(output); err != nil { if err := parse.ValidateFileName(c.Output); err != nil {
return err return err
} }
return runtime.SaveImage(getContext(), c) return runtime.SaveImage(getContext(), c)

View File

@ -46,7 +46,7 @@ func init() {
flags.StringVar(&searchCommand.Format, "format", "", "Change the output format to a Go template") flags.StringVar(&searchCommand.Format, "format", "", "Change the output format to a Go template")
flags.IntVar(&searchCommand.Limit, "limit", 0, "Limit the number of results") flags.IntVar(&searchCommand.Limit, "limit", 0, "Limit the number of results")
flags.BoolVar(&searchCommand.NoTrunc, "no-trunc", false, "Do not truncate the output") flags.BoolVar(&searchCommand.NoTrunc, "no-trunc", false, "Do not truncate the output")
flags.BoolVar(&searchCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries (default: true)") flags.BoolVar(&searchCommand.TlsVerify, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries")
} }
func searchCmd(c *cliconfig.SearchValues) error { func searchCmd(c *cliconfig.SearchValues) error {

View File

@ -41,7 +41,7 @@ func init() {
flags.StringVar(&startCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _") flags.StringVar(&startCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _")
flags.BoolVarP(&startCommand.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached") flags.BoolVarP(&startCommand.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
flags.BoolVarP(&startCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of") flags.BoolVarP(&startCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.BoolVar(&startCommand.SigProxy, "sig-proxy", true, "Proxy received signals to the process (default true if attaching, false otherwise)") flags.BoolVar(&startCommand.SigProxy, "sig-proxy", false, "Proxy received signals to the process (default true if attaching, false otherwise)")
markFlagHiddenForRemoteClient("latest", flags) markFlagHiddenForRemoteClient("latest", flags)
} }
@ -62,14 +62,10 @@ func startCmd(c *cliconfig.StartValues) error {
return errors.Errorf("you cannot start and attach multiple containers at once") return errors.Errorf("you cannot start and attach multiple containers at once")
} }
sigProxy := c.SigProxy sigProxy := c.SigProxy || attach
if sigProxy && !attach { if sigProxy && !attach {
if c.Flag("sig-proxy").Changed { return errors.Wrapf(libpod.ErrInvalidArg, "you cannot use sig-proxy without --attach")
return errors.Wrapf(libpod.ErrInvalidArg, "you cannot use sig-proxy without --attach")
} else {
sigProxy = false
}
} }
runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)