Skip to content

Commit

Permalink
CLI: 'put src-dir' vs 'archive put src-dir' usability
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Dec 5, 2023
1 parent 00d19ab commit eb7e537
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/cli/cli/arch_hdlr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
17 changes: 17 additions & 0 deletions cmd/cli/cli/object_hdlr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eb7e537

Please sign in to comment.