1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-24 08:02:33 +03:00

open folder if no arguments given

This commit is contained in:
Zack Scholl 2018-10-19 10:18:49 -07:00
parent 5ecbab6673
commit dc6493374a
2 changed files with 13 additions and 1 deletions

1
go.mod
View File

@ -15,6 +15,7 @@ require (
github.com/schollz/progressbar/v2 v2.6.0
github.com/schollz/spinner v0.0.0-20180925172146-6bbc5f7804f9
github.com/schollz/utils v1.0.0
github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c
github.com/stretchr/testify v1.2.2
github.com/tscholl2/siec v0.0.0-20180721101609-21667da05937
github.com/urfave/cli v1.20.0

View File

@ -14,6 +14,7 @@ import (
humanize "github.com/dustin/go-humanize"
"github.com/schollz/croc/src/croc"
"github.com/schollz/croc/src/utils"
"github.com/skratchdot/open-golang/open"
"github.com/urfave/cli"
)
@ -187,10 +188,20 @@ func receive(c *cli.Context) error {
if c.Args().First() != "" {
codePhrase = c.Args().First()
}
openFolder := false
if len(os.Args) == 1 {
// open folder since they didn't give any arguments
openFolder = true
}
if codePhrase == "" {
codePhrase = utils.GetInput("Enter receive code: ")
}
return cr.Receive(codePhrase)
err := cr.Receive(codePhrase)
if err == nil && openFolder {
cwd, _ := os.Getwd()
open.Run(cwd)
}
return err
}
func relay(c *cli.Context) error {