aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds/list.go21
-rw-r--r--main.go47
2 files changed, 66 insertions, 2 deletions
diff --git a/cmds/list.go b/cmds/list.go
new file mode 100644
index 0000000..14fa53d
--- /dev/null
+++ b/cmds/list.go
@@ -0,0 +1,21 @@
+package cmd
+
+import (
+ "flag"
+ "fmt"
+)
+
+func List(params []string) {
+ flags := flag.NewFlagSet("list", flag.ExitOnError)
+
+ var withPaths bool
+
+ const WITH_PATHS_HELP = "print paths to the provided reference within the snapshot"
+
+ flags.BoolVar(&withPaths, "paths", false, WITH_PATHS_HELP);
+ flags.BoolVar(&withPaths, "p", false, WITH_PATHS_HELP);
+
+ flags.Parse(params);
+
+ fmt.Printf("Your flag is: %t", withPaths);
+}
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()
+ }
+
}