all repos — min @ 435af004eb27b9d60cb97f99a9b40a4e48c73986

A small but practical concatenative programming language.

Added github tasks to draft and update releases.
h3rald h3rald@h3rald.com
Sun, 06 Dec 2020 17:36:04 +0100
commit

435af004eb27b9d60cb97f99a9b40a4e48c73986

parent

bdc7fbb2a08c47a7c041e9cb34f08204e7831dee

M .gitignore.gitignore

@@ -12,3 +12,5 @@ packages/

site/output/ site/temp/ dynlibs/ +.env.yml +response.json
A current-release.md

@@ -0,0 +1,10 @@

+* Added **apply-interpolate** (alias: **=%**) operator. +* Documented that it is possible also to interpolate with named placeholders, like this: `"Current Directory: $pwd" ("pwd" .) =%` +* Added **from-yaml** and **to-yaml** operators. Note that they only support dictionaries containing string values (primarily intended to access extremely simple YAML files containing just key/value pairs). +* Added **from-semver**, **to-semver**, **semver-major**, **semver-minor**, **semver-patch**, **semver** operators to manage version strings conforming to [Semantic Versioning](https://semver.org/) (additional labels are not yet supported). +* Automatically adding **.min** to files supplied to the min executable if they don't already end in .min. +* Fixed GC safety issues +* Now statically linking libssl and libcrypto on all platform to provide HTTPS support out of the box +* Now using a set of min tasks to perform a min release and other common operations +* Added **escape** operator to escape quotes and special characters in a string. +* Added **quit** operator to exit with a 0 code.
M lib/min_lang.nimlib/min_lang.nim

@@ -81,6 +81,8 @@ var dict = newDict(i.scope)

let lines = s.strVal.split("\n") for line in lines: let pair = line.split(":") + if pair.len == 1 and pair[0].len == 0: + continue i.dset(dict, pair[0].strip, pair[1].strip.newVal) i.push(dict) except:

@@ -208,6 +210,10 @@ def.symbol("eval") do (i: In):

let vals = i.expect("string") let s = vals[0] i.eval s.strVal + + def.symbol("quit") do (i: In): + i.push 0.newVal + i.push "exit".newSym def.symbol("parse") do (i: In): let vals = i.expect("string")

@@ -549,7 +555,6 @@ if not json.hasKey(sym):

raiseUndefined("Symbol '$1' not found." % sym) let val = i.fromJson(json[sym]) i.scope.symbols[sym] = MinOperator(kind: minValOp, val: val, quotation: true) - def.symbol("saved-symbols") do (i: In): var q = newSeq[MinValue](0)
M lib/min_str.nimlib/min_str.nim

@@ -1,6 +1,7 @@

import strutils, - sequtils + sequtils, + json import ../core/parser, ../core/value,

@@ -206,6 +207,13 @@ let v = cv.intVal + 1

i.dset(d, "patch", v.newVal) i.push(d) i.push("to-semver".newSym) + + def.symbol("escape") do (i: In): + let vals = i.expect("'sym") + let a = vals[0].getString + var s = "" + a.escapeJsonUnquoted(s) + i.push s.newVal def.symbol("=~") do (i: In): i.push("regex".newSym)
M min.ymlmin.yml

@@ -1,4 +1,5 @@

author: Fabio Cevasco description: A tiny concatenative programming language and shell. +id: 34898022 name: min version: 0.23.0
M site/contents/reference-str.mdsite/contents/reference-str.md

@@ -19,6 +19,9 @@

{#op||chr||{{i}}||{{s}}|| Returns the single character {{s}} obtained by interpreting {{i}} as an ASCII code.#} +{#op||escape||{{sl}}||{{s}}|| +Returns a copy of {{sl}} with quotes and backslashes escaped with a backslash.#} + {#op||from-semver||{{s}}||{{d}}|| Given a basic [SemVer](https://semver.org)-compliant string (with no additional labels) {{s}}, it pushes a dictionary {{d}} on the stack containing a **major**, **minor**, and **patch** key/value pairs.#}
A tasks/github.min

@@ -0,0 +1,64 @@

+".env.yml" fread from-yaml :vars +"min.yml" fread from-yaml :config +config /version :min-version +"current-release.md" fread escape :release-body +"tasks/templates/draft-release.json" fread :draft-release-template +draft-release-template ("version" min-version "body" release-body) =% :draft-release-body + +config /version :minversion +vars /github-token :token + +;"https://api.github.com/repos/h3rald/min/releases/$#/assets" (id) =% :assets-url +"https://api.github.com/repos/h3rald/min/releases" :releases-url +{} + "token $#" (token) =% %Authorization :headers +headers + +( + response to-json "response.json" fwrite + response /body from-json :body + response /status :status + (status 300 >) ( + body /message :message + status string @status + "Error $#: $#" (status message) =% error status int exit + ) when +) :handle-errors + +( + :data + data /endpoint :endpoint + "https://api.github.com/repos/h3rald/min$#" (endpoint) =% :url + {} + url %url + data /method %method + headers %headers + (data ?body) (data /body %body) when + request :response + response /status :status + response /body :body + handle-errors + body from-json +) :gh-req +( + {} + "/releases" %endpoint + "POST" %method + draft-release-body %body + gh-req /id string :id + ; Save Release ID to min.yml + config id %id to-yaml "min.yml" fwrite + "Draft release v$# ($#) created successfully" (minversion id) =% notice +) %draft-release +( + config /id :id + {} + "/releases/$#" (id) =% %endpoint + "PATCH" %method + draft-release-body %body + gh-req /id string :id + "Draft release v$# ($#) updated successfully" (minversion id) =% notice +) %update-release ++github-tasks + +
A tasks/templates/draft-release.json

@@ -0,0 +1,6 @@

+{ + "name": "v$version", + "tag_name": "v$version", + "body": "$body", + "draft": true +}