added version increment script

This commit is contained in:
hellerve
2016-08-29 19:06:24 +02:00
parent bed68d00ea
commit b0dbbb19e3
2 changed files with 32 additions and 1 deletions

30
.scripts/vincr.zp Normal file
View File

@@ -0,0 +1,30 @@
(define (die msg)
(begin
(write msg)
(exit 1)))
(define (usage)
(die "increment_version [position]\n\tposition defaults to 2"))
(define (parse-args)
(cond
((eq? 0 (length zepto:args)) 2)
((and (string:num? (car zepto:args))
(eq? 1 (length zepto:args)))
(string->number (car zepto:args)))
(else (usage))))
(define (main position)
(if (not (file-exists? "VERSION"))
(die "A version file is needed in the current directory")
(let* ((version (read-contents "VERSION"))
(new-version (|> (string:split version ".")
(curry map string->number)
list->vector
($ (vector:update % position add1))
(curry vector:map number->string)
($ (string:join % ".")))))
(with-output-file "VERSION" (curry write new-version)))))
(main (parse-args))
(exit 0)