Skip to content

Commit

Permalink
llcppg:-v
Browse files Browse the repository at this point in the history
  • Loading branch information
luoliwoshang committed Dec 2, 2024
1 parent 562f4c0 commit 13bd6c9
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions llcppg.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,30 @@ import (
"os"
"os/exec"

"github.com/goplus/llcppg/_xtool/llcppsymg/args"
"github.com/goplus/llcppg/types"
"github.com/goplus/llgo/xtool/env"
)

var verbose bool

func command(name string, args ...string) *exec.Cmd {
if verbose {
args = append([]string{"-v"}, args...)
}
return exec.Command(name, args...)
}

func llcppsymg(conf []byte) error {
cmd := exec.Command("llcppsymg", "-")
cmd := command("llcppsymg", "-")
cmd.Stdin = bytes.NewReader(conf)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}

func llcppsigfetch(conf []byte, out *io.PipeWriter) {
cmd := exec.Command("llcppsigfetch", "-")
cmd := command("llcppsigfetch", "-")
cmd.Stdin = bytes.NewReader(conf)
cmd.Stdout = out
cmd.Stderr = os.Stderr
Expand All @@ -47,24 +57,22 @@ func llcppsigfetch(conf []byte, out *io.PipeWriter) {
}

func gogensig(in io.Reader) error {
cmd := exec.Command("gogensig", "-")
cmd := command("gogensig", "-")
cmd.Stdin = in
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}

func main() {
cfgFile := "llcppg.cfg"
if len(os.Args) > 1 {
cfgFile = os.Args[1]
}
if cfgFile == "-h" || cfgFile == "--help" {
ags, _ := args.ParseArgs(os.Args[1:], nil)
if ags.Help {
fmt.Fprintln(os.Stderr, "Usage: llcppg [config-file]")
return
}
verbose = ags.Verbose

f, err := os.Open(cfgFile)
f, err := os.Open(ags.CfgFile)
check(err)
defer f.Close()

Expand Down

0 comments on commit 13bd6c9

Please sign in to comment.