diff options
Diffstat (limited to 'cmd/cat.go')
-rw-r--r-- | cmd/cat.go | 24 |
1 files changed, 11 insertions, 13 deletions
@@ -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 +} |