From a10f10119f05320fb71574ad54b3161f5a37d371 Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Wed, 21 Jul 2021 19:21:14 -0500 Subject: Add subcommand structure for diff, list, and overwrite --- cmd/cat.go | 9 +++++++++ cmd/diff.go | 21 +++++++++++++++++++++ cmd/list.go | 21 +++++++++++++++++++++ cmd/overwrite.go | 21 +++++++++++++++++++++ main.go | 8 ++++---- 5 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 cmd/cat.go create mode 100644 cmd/diff.go create mode 100644 cmd/list.go create mode 100644 cmd/overwrite.go diff --git a/cmd/cat.go b/cmd/cat.go new file mode 100644 index 0000000..99b48fb --- /dev/null +++ b/cmd/cat.go @@ -0,0 +1,9 @@ +package cmd + +import ( + "fmt" +) + +func Cat(params []string) { + fmt.Println(params) +} \ No newline at end of file diff --git a/cmd/diff.go b/cmd/diff.go new file mode 100644 index 0000000..7caf96b --- /dev/null +++ b/cmd/diff.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "flag" + "fmt" +) + +func Diff(params []string) { + flags := flag.NewFlagSet("diff", flag.ExitOnError) + + var walk bool + + const WALK_HELP = "walk backwards through the diff history" + + flags.BoolVar(&walk, "walk", false, WALK_HELP); + flags.BoolVar(&walk, "w", false, WALK_HELP); + + flags.Parse(params); + + fmt.Printf("Your flag is: %t", walk); +} diff --git a/cmd/list.go b/cmd/list.go new file mode 100644 index 0000000..d2b9a03 --- /dev/null +++ b/cmd/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/cmd/overwrite.go b/cmd/overwrite.go new file mode 100644 index 0000000..6f4a00b --- /dev/null +++ b/cmd/overwrite.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "flag" + "fmt" +) + +func Overwrite(params [] string) { + flags := flag.NewFlagSet("overwrite", flag.ExitOnError); + + var withBackup bool + + const WITH_BACKUP_HELP = "backup the file by creating a snapshot" + + flags.BoolVar(&withBackup, "backup", false, WITH_BACKUP_HELP); + flags.BoolVar(&withBackup, "b", false, WITH_BACKUP_HELP); + + flags.Parse(params); + + fmt.Printf("Your flag is: %t", withBackup); +} \ No newline at end of file diff --git a/main.go b/main.go index ea477f4..31a9640 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,7 @@ import ( "os" "io" "fmt" - "golang.flu0r1ne.net/zfdiff/cmds" + "golang.flu0r1ne.net/zfdiff/cmd" ) func printUsage(w io.Writer) { @@ -35,11 +35,11 @@ func main() { case "list": cmd.List(subargs) case "overwrite": - //overwrite(subargs) + cmd.Overwrite(subargs) case "cat": - //cmd.Cat(subargs) + cmd.Cat(subargs) case "diff": - //diff(subargs) + cmd.Diff(subargs) case "-h", "-help", "--help", "help": printUsage(os.Stdout) default: -- cgit v1.2.3