diff --git a/.scripts/vincr.zp b/.scripts/vincr.zp new file mode 100644 index 0000000..5721b63 --- /dev/null +++ b/.scripts/vincr.zp @@ -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) diff --git a/zshrc b/zshrc index 2b49a36..2d1a6e9 100644 --- a/zshrc +++ b/zshrc @@ -38,6 +38,7 @@ alias dob="git branch --merged | grep -vE '(\*)|(master)|(dev)' | xargs -n 1 git alias vi="stty stop '' -ixoff ; vim" alias gcc="gcc-6" alias g++="g++-6" +alias increment_version="zepto ~/.scripts/vincr.zp" alias psh="perl ~/.scripts/psh" alias push="git push" alias pull="git pull" @@ -418,4 +419,4 @@ function zeptosay () { fortune | zeptosay -#source ~/.zshrc.priv +source ~/.zshrc.priv