diff options
author | Ed Santiago <santiago@redhat.com> | 2019-06-11 05:55:16 -0600 |
---|---|---|
committer | Ed Santiago <santiago@redhat.com> | 2019-06-11 06:53:03 -0600 |
commit | 9f49c1af46f9272c25db44c6e3e6ff9ec96aad4c (patch) | |
tree | ead6223887602ff6c085f5142d3ecee5a1f0b567 /cmd/podman | |
parent | bd0582dd3407a1f1ad5c38753d84243dcdf63102 (diff) | |
download | podman-9f49c1af46f9272c25db44c6e3e6ff9ec96aad4c.tar.gz podman-9f49c1af46f9272c25db44c6e3e6ff9ec96aad4c.tar.bz2 podman-9f49c1af46f9272c25db44c6e3e6ff9ec96aad4c.zip |
Prohibit use of positional args with --import
I took the liberty of combining related checks together
so as to avoid a little duplication; if this is not a
Go best practice, I will revert. I also made a minor
wording adjustment to an error message for clarity.
Also: update wording of man page.
Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/restore.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cmd/podman/restore.go b/cmd/podman/restore.go index 4d715ad4f..6e445e5df 100644 --- a/cmd/podman/restore.go +++ b/cmd/podman/restore.go @@ -76,11 +76,16 @@ func restoreCmd(c *cliconfig.RestoreValues, cmd *cobra.Command) error { return errors.Errorf("--tcp-established cannot be used with --name") } - if (c.Import != "") && (c.All || c.Latest) { - return errors.Errorf("Cannot use --import and --all or --latest at the same time") + argLen := len(c.InputArgs) + if c.Import != "" { + if c.All || c.Latest { + return errors.Errorf("Cannot use --import with --all or --latest") + } + if argLen > 0 { + return errors.Errorf("Cannot use --import with positional arguments") + } } - argLen := len(c.InputArgs) if (c.All || c.Latest) && argLen > 0 { return errors.Errorf("no arguments are needed with --all or --latest") } |