summaryrefslogtreecommitdiff
path: root/find-version.sh
blob: 4ac390e6e52ec4287245f40ce438c0af19373413 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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"))))