From 2de73cb138a9fc5128b565356ebffbdd8771bb41 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Sat, 19 Sep 2020 17:52:32 +0200 Subject: [PATCH] show all files when sending without send command --- src/cli/cli.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/cli/cli.go b/src/cli/cli.go index f126ad0..05cef32 100644 --- a/src/cli/cli.go +++ b/src/cli/cli.go @@ -89,10 +89,23 @@ func Run() (err error) { app.HideHelp = false app.HideVersion = false app.Action = func(c *cli.Context) error { + allStringsAreFiles := func(strs []string) bool { + for _, str := range strs { + if !utils.Exists(str) { + return false; + } + } + return true; + } + // if trying to send but forgot send, let the user know - if c.Args().First() != "" && utils.Exists(c.Args().First()) { - _, fname := filepath.Split(c.Args().First()) - yn := utils.GetInput(fmt.Sprintf("Did you mean to send '%s'? (y/n) ", fname)) + if c.Args().Present() && allStringsAreFiles(c.Args().Slice()) { + fnames := []string{} + for _, fpath := range c.Args().Slice() { + _, basename := filepath.Split(fpath) + fnames = append(fnames, "'" + basename + "'") + } + yn := utils.GetInput(fmt.Sprintf("Did you mean to send %s? (y/n) ", strings.Join(fnames, ", "))) if strings.ToLower(yn) == "y" { return send(c) }