aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/vlib/semver/util.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/old/vlib/semver/util.v
downloadcli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.gz
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.bz2
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/old/vlib/semver/util.v')
-rw-r--r--v_windows/v/old/vlib/semver/util.v55
1 files changed, 55 insertions, 0 deletions
diff --git a/v_windows/v/old/vlib/semver/util.v b/v_windows/v/old/vlib/semver/util.v
new file mode 100644
index 0000000..142ce19
--- /dev/null
+++ b/v_windows/v/old/vlib/semver/util.v
@@ -0,0 +1,55 @@
+module semver
+
+// * Private functions.
+[inline]
+fn is_version_valid(input string) bool {
+ raw_ver := parse(input)
+ return raw_ver.is_valid()
+}
+
+[inline]
+fn coerce_version(input string) ?Version {
+ raw_ver := parse(input)
+ ver := raw_ver.coerce() or { return error('Invalid version for input "$input"') }
+ return ver
+}
+
+[inline]
+fn increment_version(ver Version, typ Increment) Version {
+ mut major := ver.major
+ mut minor := ver.minor
+ mut patch := ver.patch
+ match typ {
+ .major {
+ major++
+ minor = 0
+ patch = 0
+ }
+ .minor {
+ minor++
+ patch = 0
+ }
+ .patch {
+ patch++
+ }
+ }
+ return Version{major, minor, patch, ver.prerelease, ver.metadata}
+}
+
+fn is_valid_string(input string) bool {
+ for c in input {
+ if !(c.is_letter() || c.is_digit() || c == `.` || c == `-`) {
+ return false
+ }
+ }
+ return true
+}
+
+fn is_valid_number(input string) bool {
+ for c in input {
+ if !c.is_digit() {
+ return false
+ }
+ }
+ return true
+}