mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
Merge pull request #421 from jolheiser/wildcard
Add wildcard support for files
This commit is contained in:
commit
914d0c98a8
1 changed files with 13 additions and 6 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue