From eb7e5373835a733a49bd1d9b4423a76f0c9c5029 Mon Sep 17 00:00:00 2001 From: Alex Aizman Date: Tue, 5 Dec 2023 17:05:41 -0500 Subject: [PATCH] CLI: 'put src-dir' vs 'archive put src-dir' usability Signed-off-by: Alex Aizman --- cmd/cli/cli/arch_hdlr.go | 10 ++++++++-- cmd/cli/cli/object_hdlr.go | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/cmd/cli/cli/arch_hdlr.go b/cmd/cli/cli/arch_hdlr.go index 351cb753377..278caea4419 100644 --- a/cmd/cli/cli/arch_hdlr.go +++ b/cmd/cli/cli/arch_hdlr.go @@ -289,10 +289,16 @@ func putApndArchHandler(c *cli.Context) (err error) { // multi-file cases // if !a.appendOnly && !a.appendOrPut { - warn := fmt.Sprintf("multi-file 'archive put' operation requires either %s or %s", + warn := fmt.Sprintf("multi-file 'archive put' operation requires either %s or %s (command line)", qflprn(archAppendOnlyFlag), qflprn(archAppendOrPutFlag)) actionWarn(c, warn) - fmt.Fprintf(c.App.ErrWriter, "Assuming %s - proceeding to execute...\n\n", qflprn(archAppendOrPutFlag)) + if flagIsSet(c, yesFlag) { + fmt.Fprintf(c.App.ErrWriter, "Assuming %s - proceeding to execute...\n\n", qflprn(archAppendOrPutFlag)) + } else { + if ok := confirm(c, fmt.Sprintf("Proceed to execute 'archive put %s'?", flprn(archAppendOrPutFlag))); !ok { + return + } + } a.appendOrPut = true } diff --git a/cmd/cli/cli/object_hdlr.go b/cmd/cli/cli/object_hdlr.go index c8187ddd954..2fa9302f8ed 100644 --- a/cmd/cli/cli/object_hdlr.go +++ b/cmd/cli/cli/object_hdlr.go @@ -13,6 +13,7 @@ import ( "github.com/NVIDIA/aistore/api" "github.com/NVIDIA/aistore/cmd/cli/teb" "github.com/NVIDIA/aistore/cmn" + "github.com/NVIDIA/aistore/cmn/archive" "github.com/NVIDIA/aistore/cmn/cos" "github.com/NVIDIA/aistore/cmn/debug" "github.com/urfave/cli" @@ -307,6 +308,22 @@ func putHandler(c *cli.Context) (err error) { default: // one directory var ndir int + if a.dst.oname != "" { + warn := fmt.Sprintf("'%s' will be used as a destination name prefix for all files from '%s'", + a.dst.oname, a.src.arg) + actionWarn(c, warn) + if _, err := archive.Mime(a.dst.oname, ""); err == nil { + warn := fmt.Sprintf("did you want to use 'archive put' instead, with %q as the destination?", + a.dst.oname) + actionWarn(c, warn) + } + if !flagIsSet(c, yesFlag) { + if ok := confirm(c, "Proceed anyway?"); !ok { + return + } + } + } + fobjs, err := lsFobj(c, a.src.abspath, "", a.dst.oname, &ndir, a.src.recurs, incl) if err != nil { return err