summaryrefslogtreecommitdiff
path: root/find-version.sh
diff options
context:
space:
mode:
Diffstat (limited to 'find-version.sh')
-rwxr-xr-xfind-version.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/find-version.sh b/find-version.sh
new file mode 100755
index 0000000..4ac390e
--- /dev/null
+++ b/find-version.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+":"; exec emacs --quick --script "$0" -- "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
+
+(with-temp-buffer
+ (insert-file-contents "Cargo.toml")
+ (goto-char (point-min))
+ (cond
+ ((search-forward "version =" nil t)
+ (re-search-forward " *" (line-end-position) t)
+ (cond
+ ((= (char-after) 34))
+ ((error "Invalid syntax at %d" (point))))
+ (let ((end (line-end-position)))
+ (cond
+ ((= (char-before end) 34))
+ ((error "Invalid syntax at %d" (1- end))))
+ (princ
+ (buffer-substring-no-properties
+ (1+ (point)) (1- end)))))
+ ((print "Unknown"))))