From 1e124306dbd35a4cfdf3f585119a2c4441ec543d Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Thu, 14 Mar 2019 08:47:15 -0600 Subject: save-load-export: clear cli-parsing default ...in order to silence Cobra's usually-helpful "(default xxx)" message. Initialization is now done in code, by testing for empty string and setting that to /dev/std{in,out} as appropriate; make special note of load.go where there's mild duplication between a local variable and cliconfig. Signed-off-by: Ed Santiago --- cmd/podman/save.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cmd/podman/save.go') diff --git a/cmd/podman/save.go b/cmd/podman/save.go index 807f8b132..c10679740 100644 --- a/cmd/podman/save.go +++ b/cmd/podman/save.go @@ -58,7 +58,7 @@ func init() { 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.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 instead of terminal") + 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") } @@ -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'") } - output := c.Output - if output == "/dev/stdout" { + if len(c.Output) == 0 { fi := os.Stdout if logrus.IsTerminal(fi) { 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 runtime.SaveImage(getContext(), c) -- cgit v1.2.3-54-g00ecf