0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

prompt user if accidently receiving

This commit is contained in:
Zack Scholl 2018-11-01 07:08:57 -07:00
parent aefb15105a
commit a56334fc60

View file

@ -95,6 +95,14 @@ func Run() {
fmt.Fprintf(c.App.Writer, "send\nreceive\relay")
}
app.Action = func(c *cli.Context) error {
// 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 strings.ToLower(yn) == "y" {
return send(c)
}
}
return receive(c)
}
app.Before = func(c *cli.Context) error {