aboutsummaryrefslogtreecommitdiff
path: root/snap/parsing.go
diff options
context:
space:
mode:
Diffstat (limited to 'snap/parsing.go')
-rw-r--r--snap/parsing.go29
1 files changed, 17 insertions, 12 deletions
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])
}