diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2017-05-07 22:46:38 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2017-05-07 23:02:08 +0200 |
| commit | 36b903423828b2e35c9c1fde3fdc898fe2ed23ca (patch) | |
| tree | 22770bbade8c8e20a3b6f4e9f5a91ed9d5580f89 /main.go | |
| parent | 385645d1a0bb9ae618e92d2e7a2ea6fe256b5ba2 (diff) | |
| download | gofu-36b903423828b2e35c9c1fde3fdc898fe2ed23ca.tar.gz | |
refactor towards new cli.Interface
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -23,26 +23,32 @@ import ( "os" "path/filepath" + "github.com/majewsky/gofu/pkg/cli" "github.com/majewsky/gofu/pkg/rtree" ) func main() { - os.Exit(execApplet(filepath.Base(os.Args[0]), os.Args[1:], true)) + ci, err := cli.NewInterface(os.Stdin, os.Stdout, os.Stderr) + if err != nil { + fmt.Fprintln(os.Stderr, "FATAL: initialization failed") + os.Exit(255) + } + os.Exit(execApplet(ci, filepath.Base(os.Args[0]), os.Args[1:], true)) } -func execApplet(applet string, args []string, allowGofu bool) int { +func execApplet(ci *cli.Interface, applet string, args []string, allowGofu bool) int { //allow explicit specification of applet as "./build/gofu <applet> <args>" if allowGofu && applet == "gofu" { if len(args) == 0 { fmt.Fprintln(os.Stderr, "Usage: gofu <applet> [args...]") return 1 } - return execApplet(args[0], args[1:], false) + return execApplet(ci, args[0], args[1:], false) } switch applet { case "rtree": - return rtree.Exec(args) + return rtree.Exec(ci, args) default: fmt.Fprintln(os.Stderr, "ERROR: unknown applet: "+applet) return 255 |
