aboutsummaryrefslogtreecommitdiff
path: root/snap/parsing.go
diff options
context:
space:
mode:
authorflu0r1ne <flu0r1ne@flu0r1ne.net>2021-07-29 13:09:23 -0500
committerflu0r1ne <flu0r1ne@flu0r1ne.net>2021-07-29 13:09:23 -0500
commit2c10158ce92f102280d4d87406ebeea3e05bf915 (patch)
tree61797fcdea06e128a04af05ce611f9babc0a8775 /snap/parsing.go
parent34d7d612dd376258248ee6cae07b839951fccf32 (diff)
downloadzsu-2c10158ce92f102280d4d87406ebeea3e05bf915.tar.xz
zsu-2c10158ce92f102280d4d87406ebeea3e05bf915.zip
Added README, Licence, and fixed issue with modules
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])
}