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

Add wildcard support

Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
jolheiser 2021-10-01 16:49:21 -05:00
parent e19e06a652
commit e380c7b1f1
No known key found for this signature in database
GPG key ID: B853ADA5DA7BBF7A

View file

@ -70,18 +70,14 @@ func Run() (err error) {
&cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the local relay (optional)"}, &cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the local relay (optional)"},
}, },
HelpName: "croc send", HelpName: "croc send",
Action: func(c *cli.Context) error { Action: send,
return send(c)
},
}, },
{ {
Name: "relay", Name: "relay",
Usage: "start your own relay (optional)", Usage: "start your own relay (optional)",
Description: "start relay", Description: "start relay",
HelpName: "croc relay", HelpName: "croc relay",
Action: func(c *cli.Context) error { Action: relay,
return relay(c)
},
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the relay"}, &cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the relay"},
}, },
@ -352,6 +348,17 @@ func getPaths(fnames []string) (paths []string, haveFolder bool, err error) {
haveFolder = false haveFolder = false
paths = []string{} paths = []string{}
for _, fname := range fnames { for _, fname := range fnames {
// Support wildcard
if strings.Contains(fname, "*") {
matches, errGlob := filepath.Glob(fname)
if errGlob != nil {
err = errGlob
return
}
paths = append(paths, matches...)
continue
}
stat, errStat := os.Lstat(fname) stat, errStat := os.Lstat(fname)
if errStat != nil { if errStat != nil {
err = errStat err = errStat