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 --- snap/parsing.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'snap/parsing.go') diff --git a/snap/parsing.go b/snap/parsing.go index fcacec9..0d1f09f 100644 --- a/snap/parsing.go +++ b/snap/parsing.go @@ -18,11 +18,6 @@ func parseEscaped(snapish string) *Relative { if isEscaped(snapish) { snapshot := strings.Trim(snapish, `"`); - if(snapshot == "") { - die.Fatal("Snapshot cannot be empty \"\"") - - } - return &Relative { snapshot: snapshot, } @@ -69,7 +64,7 @@ func parseRelativeSyntax(snapish, directionToken string) *Relative { } } -func ToRelative(snapish string) * Relative { +func toRelative(snapish string) * Relative { if ref := parseEscaped(snapish); ref != nil { return ref; } @@ -78,7 +73,7 @@ func ToRelative(snapish string) * Relative { return ref; } - if ref := parseRelativeSyntax(snapish, "^"); ref != nil { + if ref := parseRelativeSyntax(snapish, "-"); ref != nil { ref.offset = -ref.offset; return ref; } @@ -88,16 +83,26 @@ func ToRelative(snapish string) * Relative { }; } -func ParseDiff(snapdiff string) (fromRel, toRel *Relative) { - snapishes := strings.Split(snapdiff, "..") +func ToRelative(snapish string) * Relative { + rel := toRelative(snapish) + + if rel.snapshot == "" { + die.Fatal("Please provide a snapshot. You can use @ for the current filesystem and $ for the last snapshot.") + } + + return rel +} + +func ParseDiff(snapishdiff string) (fromRel, toRel *Relative) { + snapishes := strings.Split(snapishdiff, "..") - if(len(snapishes) > 2) { + if len(snapishes) > 2 { die.Fatal("Cannot diff more than two snapshots"); } fromRel = ToRelative(snapishes[0]) - toRel = &Relative{} - if(len(snapishes) == 2) { + toRel = &Relative{snapshot: "@"} + if len(snapishes) == 2 { toRel = ToRelative(snapishes[1]) } -- cgit v1.2.3