mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
show all files when sending without send command
This commit is contained in:
parent
20a8603ffe
commit
2de73cb138
1 changed files with 16 additions and 3 deletions
|
@ -89,10 +89,23 @@ func Run() (err error) {
|
||||||
app.HideHelp = false
|
app.HideHelp = false
|
||||||
app.HideVersion = false
|
app.HideVersion = false
|
||||||
app.Action = func(c *cli.Context) error {
|
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 trying to send but forgot send, let the user know
|
||||||
if c.Args().First() != "" && utils.Exists(c.Args().First()) {
|
if c.Args().Present() && allStringsAreFiles(c.Args().Slice()) {
|
||||||
_, fname := filepath.Split(c.Args().First())
|
fnames := []string{}
|
||||||
yn := utils.GetInput(fmt.Sprintf("Did you mean to send '%s'? (y/n) ", fname))
|
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" {
|
if strings.ToLower(yn) == "y" {
|
||||||
return send(c)
|
return send(c)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue