aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go47
1 files changed, 45 insertions, 2 deletions
diff --git a/main.go b/main.go
index 8bc5cc2..ea477f4 100644
--- a/main.go
+++ b/main.go
@@ -1,7 +1,50 @@
package main
-import "fmt"
+import (
+ "os"
+ "io"
+ "fmt"
+ "golang.flu0r1ne.net/zfdiff/cmds"
+)
+
+func printUsage(w io.Writer) {
+ fmt.Fprintf (w, "usage: %s command args ... \n", os.Args[0])
+ fmt.Fprintln(w, " help ")
+ fmt.Fprintln(w, " version ")
+ fmt.Fprintln(w, " list [-paths|-p] <reference> ")
+ fmt.Fprintln(w, " diff [-walk|-w] <snap-ish>..<snap-ish> <reference> ")
+ fmt.Fprintln(w, " cat <snap-ish> <reference> ")
+ fmt.Fprintln(w, " overwrite [-backup|-b] <snap-ish> <reference> ")
+}
+
+func dieUsage() {
+ printUsage(os.Stderr)
+ os.Exit(1)
+}
func main() {
- fmt.Println("Hello");
+
+ if len(os.Args) < 2 {
+ dieUsage()
+ }
+
+ subcommand := os.Args[1]
+ subargs := os.Args[2:]
+
+ switch subcommand {
+ case "list":
+ cmd.List(subargs)
+ case "overwrite":
+ //overwrite(subargs)
+ case "cat":
+ //cmd.Cat(subargs)
+ case "diff":
+ //diff(subargs)
+ case "-h", "-help", "--help", "help":
+ printUsage(os.Stdout)
+ default:
+ fmt.Fprintf(os.Stderr, "unrecognized command %s\n", subcommand)
+ dieUsage()
+ }
+
}