aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2017-05-07 22:46:38 +0200
committerStefan Majewsky <majewsky@gmx.net>2017-05-07 23:02:08 +0200
commit36b903423828b2e35c9c1fde3fdc898fe2ed23ca (patch)
tree22770bbade8c8e20a3b6f4e9f5a91ed9d5580f89 /main.go
parent385645d1a0bb9ae618e92d2e7a2ea6fe256b5ba2 (diff)
downloadgofu-36b903423828b2e35c9c1fde3fdc898fe2ed23ca.tar.gz
refactor towards new cli.Interface
Diffstat (limited to 'main.go')
-rw-r--r--main.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/main.go b/main.go
index ea34c2e..ef0bf62 100644
--- a/main.go
+++ b/main.go
@@ -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