Allow multiple -command flags (#552)

This commit is contained in:
Marius authored and GitHub committed 2021-01-07 01:10:54 +03:00
1 parent b5f6f6edee
commit 8e09df5969
2 files changed
+16 -5

No files matched your search

+2 -2
View File
@@ -183,8 +183,8 @@ func (app *app) loop() {
}
}
if gCommand != "" {
p := newParser(strings.NewReader(gCommand))
for _, cmd := range gCommands {
p := newParser(strings.NewReader(cmd))
for p.parse() {
p.expr.eval(app, nil)
+14 -3
View File
@@ -11,6 +11,7 @@ import (
"runtime"
"runtime/pprof"
"strconv"
"strings"
)
var (
@@ -18,6 +19,8 @@ var (
envLevel = os.Getenv("LF_LEVEL")
)
type arrayFlag []string
var (
gClientID int
gHostname string
@@ -28,10 +31,19 @@ var (
gLogPath string
gServerLogPath string
gSelect string
gCommand string
gCommands arrayFlag
gVersion string
)
func (a *arrayFlag) Set(v string) error {
*a = append(*a, v)
return nil
}
func (a *arrayFlag) String() string {
return strings.Join(*a, ", ")
}
func init() {
h, err := os.Hostname()
if err != nil {
@@ -205,9 +217,8 @@ func main() {
"",
"path to the file to write selected files on open (to use as open file dialog)")
flag.StringVar(&gCommand,
flag.Var(&gCommands,
"command",
"",
"command to execute on client initialization")
flag.Parse()