From 2c10158ce92f102280d4d87406ebeea3e05bf915 Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Thu, 29 Jul 2021 13:09:23 -0500 Subject: Added README, Licence, and fixed issue with modules --- cmd/cat.go | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'cmd/cat.go') diff --git a/cmd/cat.go b/cmd/cat.go index 186f7da..f3ea2bf 100644 --- a/cmd/cat.go +++ b/cmd/cat.go @@ -2,7 +2,7 @@ package cmd import ( "fmt" - "golang.flu0r1ne.net/zfdiff/snap" + "golang.flu0r1ne.net/zsu/snap" "os" "io" ) @@ -14,34 +14,32 @@ func Cat(params []string) { die.Fatal("Reference file is required") } - if(n_params > 3) { + if(n_params > 2) { die.Fatal("Too many arguments provided") } - var reference string - snapish := "" + reference := params[0] - if(n_params == 1) { - reference = params[0] - } else { - snapish, reference = params[0], params[1] + snapish := "@" + if(n_params > 1) { + snapish = params[1] } snapRef := snap.ToRelative(snapish) oracle := snap.GetOracle(reference) - path := oracle.ResolveRelative(snapRef) + path := oracle.PathTo(snapRef) file, err := os.Open(path) if err != nil { - die.Fatal("Could not open snapshot %s\nError: %v", path, err) + die.Fatalf("Could not open snapshot %s\nError: %v", path, err) } defer func() { if err = file.Close(); err != nil { - die.Fatal("Could not close file %s\nError: %v", path, err) + die.Fatalf("Could not close file %s\nError: %v", path, err) } }() @@ -59,7 +57,7 @@ func Cat(params []string) { } if err != nil { - die.Fatal("Encountered error while reading file: %v", err) + die.Fatalf("Encountered error while reading file: %v", err) } } -} \ No newline at end of file +} -- cgit v1.2.3