mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-02 22:50:18 +00:00
Seems to work for me, @AudriusButkevicius.
This commit is contained in:
parent
b71a930bfc
commit
c53a1f210c
@ -10,7 +10,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
"github.com/flynn-archive/go-shlex"
|
"github.com/flynn-archive/go-shlex"
|
||||||
@ -75,15 +74,21 @@ func (*stdinCommand) Run() error {
|
|||||||
if len(input) == 0 {
|
if len(input) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
cmd := exec.Command(os.Args[0], append(args[1:], input...)...)
|
|
||||||
out, err := cmd.CombinedOutput()
|
var cli CLI
|
||||||
fmt.Print(string(out))
|
p, err := kong.New(&cli)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(*exec.ExitError); ok {
|
// can't happen, really
|
||||||
// we will continue loop no matter the command succeeds or not
|
return fmt.Errorf("creating parser: %w", err)
|
||||||
continue
|
}
|
||||||
}
|
ctx, err := p.Parse(input)
|
||||||
return err
|
if err != nil {
|
||||||
|
fmt.Println("Error:", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := ctx.Run(); err != nil {
|
||||||
|
fmt.Println("Error:", err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return scanner.Err()
|
return scanner.Err()
|
||||||
|
Loading…
Reference in New Issue
Block a user