Minor changes.
h3rald h3rald@h3rald.com
Thu, 10 Dec 2020 22:20:32 +0100
4 files changed,
238 insertions(+),
237 deletions(-)
M
lib/min_sys.nim
→
lib/min_sys.nim
@@ -1,231 +1,232 @@
-import - os, - osproc, - strutils, - sequtils, - logging -import - ../core/parser, - ../core/value, - ../core/interpreter, - ../core/utils, - ../core/fileutils - -when not defined(lite): - import ../packages/nim-miniz/src/nim_miniz - -proc unix(s: string): string = - return s.replace("\\", "/") - -proc sys_module*(i: In)= - let def = i.define() - - def.symbol(".") do (i: In): - i.push newVal(getCurrentDir().unix) - - def.symbol("..") do (i: In): - i.push newVal(getCurrentDir().parentDir.unix) - - def.symbol("cd") do (i: In): - let vals = i.expect("'sym") - let f = vals[0].getString - i.pwd = joinPath(getCurrentDir(), f) - info("Current directory changed to: ", i.pwd) - f.setCurrentDir - - def.symbol("ls") do (i: In): - let vals = i.expect("'sym") - let a = vals[0] - var list = newSeq[MinValue](0) - for i in walkDir(a.getString): - list.add newVal(i.path.unix) - i.push list.newVal - - def.symbol("ls-r") do (i: In): - let vals = i.expect("'sym") - let a = vals[0] - var list = newSeq[MinValue](0) - for i in walkDirRec(a.getString): - list.add newVal(i.unix) - i.push list.newVal - - def.symbol("system") do (i: In): - let vals = i.expect("'sym") - let a = vals[0] - i.push execShellCmd(a.getString).newVal - - def.symbol("system!") do (i: In): - let vals = i.expect("'sym") - let a = vals[0] - discard execShellCmd(a.getString) - - def.symbol("run") do (i: In): - let vals = i.expect("'sym") - let cmd = vals[0] - let res = execCmdEx(cmd.getString) - var d = newDict(i.scope) - i.dset(d, "output", res.output.newVal) - i.dset(d, "code", res.exitCode.newVal) - i.push(d) - - def.symbol("get-env") do (i: In): - let vals = i.expect("'sym") - let a = vals[0] - i.push a.getString.getEnv.newVal - - def.symbol("put-env") do (i: In): - let vals = i.expect("'sym", "'sym") - let key = vals[0] - let value = vals[1] - key.getString.putEnv value.getString - - def.symbol("env?") do (i: In): - let vals = i.expect("'sym") - let s = vals[0] - i.push s.getString.existsEnv.newVal - - def.symbol("which") do (i: In): - let vals = i.expect("'sym") - let s = vals[0] - i.push s.getString.findExe.newVal - - def.symbol("os") do (i: In): - i.push hostOS.newVal - - def.symbol("cpu") do (i: In): - i.push hostCPU.newVal - - def.symbol("exists?") do (i: In): - let vals = i.expect("'sym") - let f = vals[0] - i.push newVal(f.getString.fileExists or f.getString.dirExists) - - def.symbol("file?") do (i: In): - let vals = i.expect("'sym") - let f = vals[0] - i.push f.getString.fileExists.newVal - - def.symbol("dir?") do (i: In): - let vals = i.expect("'sym") - let f = vals[0] - i.push f.getString.dirExists.newVal - - def.symbol("rm") do (i: In): - let vals = i.expect("'sym") - let v = vals[0] - let f = v.getString - if f.fileExists: - f.removeFile - else: - raiseInvalid("File '$1' does not exist." % f) - - def.symbol("cp") do (i: In): - let vals = i.expect("'sym", "'sym") - let a = vals[0] - let b = vals[1] - let src = b.getString - var dest = a.getString - if src.dirExists: - copyDirWithPermissions src, dest - elif dest.dirExists: - if src.dirExists: - copyDirWithPermissions src, dest - else: - copyFileWithPermissions src, dest / src.extractFilename - else: - copyFileWithPermissions src, dest - - def.symbol("mv") do (i: In): - let vals = i.expect("'sym", "'sym") - let a = vals[0] - let b = vals[1] - let src = b.getString - var dest = a.getString - if dest.dirExists: - dest = dest / src.extractFilename - moveFile src, dest - - def.symbol("rmdir") do (i: In): - let vals = i.expect("'sym") - let f = vals[0] - f.getString.removeDir - - def.symbol("mkdir") do (i: In): - let vals = i.expect("'sym") - let f = vals[0] - f.getString.createDir - - def.symbol("sleep") do (i: In): - let vals = i.expect("int") - let ms = vals[0] - sleep ms.intVal.int - - def.symbol("chmod") do (i: In): - let vals = i.expect("int", "string") - let perms = vals[0] - let s = vals[1] - s.getString.setFilePermissions(perms.intVal.toFilePermissions) - - def.symbol("symlink?") do (i: In): - let vals = i.expect("'sym") - let s = vals[0] - i.push s.getString.symlinkExists.newVal - - def.symbol("symlink") do (i: In): - let vals = i.expect("'sym", "'sym") - let dest = vals[0] - let src = vals[1] - src.getString.createSymlink dest.getString - - def.symbol("hardlink") do (i: In): - let vals = i.expect("'sym", "'sym") - let dest = vals[0] - let src = vals[1] - src.getString.createHardlink dest.getString - - def.symbol("filename") do (i: In): - let vals = i.expect("'sym") - let f = vals[0] - i.push f.getString.extractFilename.unix.newVal - - def.symbol("dirname") do (i: In): - let vals = i.expect("'sym") - let f = vals[0] - i.push f.getString.parentDir.unix.newVal - - def.symbol("$") do (i: In): - i.push("get-env".newSym) - - def.symbol("!") do (i: In): - i.push("system".newSym) - - def.symbol("!!") do (i: In): - i.push("system!".newSym) - - def.symbol("&") do (i: In): - i.push("run".newSym) - - def.sigil("$") do (i: In): - i.push("get-env".newSym) - - def.sigil("!") do (i: In): - i.push("system".newSym) - - def.sigil("&") do (i: In): - i.push("run".newSym) - - when not defined(lite): - def.symbol("unzip") do (i: In): - let vals = i.expect("'sym", "'sym") - let dir = vals[0] - let f = vals[1] - nim_miniz.unzip(f.getString, dir.getString) - - def.symbol("zip") do (i: In): - let vals = i.expect("'sym", "quot") - let file = vals[0] - let files = vals[1] - nim_miniz.zip(files.qVal.mapIt(it.getString), file.getString) - - def.finalize("sys") - +import + os, + osproc, + strutils, + logging +when not defined(lite): + import sequtils +import + ../core/parser, + ../core/value, + ../core/interpreter, + ../core/utils, + ../core/fileutils + +when not defined(lite): + import ../packages/nim-miniz/src/nim_miniz + +proc unix(s: string): string = + return s.replace("\\", "/") + +proc sys_module*(i: In)= + let def = i.define() + + def.symbol(".") do (i: In): + i.push newVal(getCurrentDir().unix) + + def.symbol("..") do (i: In): + i.push newVal(getCurrentDir().parentDir.unix) + + def.symbol("cd") do (i: In): + let vals = i.expect("'sym") + let f = vals[0].getString + i.pwd = joinPath(getCurrentDir(), f) + info("Current directory changed to: ", i.pwd) + f.setCurrentDir + + def.symbol("ls") do (i: In): + let vals = i.expect("'sym") + let a = vals[0] + var list = newSeq[MinValue](0) + for i in walkDir(a.getString): + list.add newVal(i.path.unix) + i.push list.newVal + + def.symbol("ls-r") do (i: In): + let vals = i.expect("'sym") + let a = vals[0] + var list = newSeq[MinValue](0) + for i in walkDirRec(a.getString): + list.add newVal(i.unix) + i.push list.newVal + + def.symbol("system") do (i: In): + let vals = i.expect("'sym") + let a = vals[0] + i.push execShellCmd(a.getString).newVal + + def.symbol("system!") do (i: In): + let vals = i.expect("'sym") + let a = vals[0] + discard execShellCmd(a.getString) + + def.symbol("run") do (i: In): + let vals = i.expect("'sym") + let cmd = vals[0] + let res = execCmdEx(cmd.getString) + var d = newDict(i.scope) + i.dset(d, "output", res.output.newVal) + i.dset(d, "code", res.exitCode.newVal) + i.push(d) + + def.symbol("get-env") do (i: In): + let vals = i.expect("'sym") + let a = vals[0] + i.push a.getString.getEnv.newVal + + def.symbol("put-env") do (i: In): + let vals = i.expect("'sym", "'sym") + let key = vals[0] + let value = vals[1] + key.getString.putEnv value.getString + + def.symbol("env?") do (i: In): + let vals = i.expect("'sym") + let s = vals[0] + i.push s.getString.existsEnv.newVal + + def.symbol("which") do (i: In): + let vals = i.expect("'sym") + let s = vals[0] + i.push s.getString.findExe.newVal + + def.symbol("os") do (i: In): + i.push hostOS.newVal + + def.symbol("cpu") do (i: In): + i.push hostCPU.newVal + + def.symbol("exists?") do (i: In): + let vals = i.expect("'sym") + let f = vals[0] + i.push newVal(f.getString.fileExists or f.getString.dirExists) + + def.symbol("file?") do (i: In): + let vals = i.expect("'sym") + let f = vals[0] + i.push f.getString.fileExists.newVal + + def.symbol("dir?") do (i: In): + let vals = i.expect("'sym") + let f = vals[0] + i.push f.getString.dirExists.newVal + + def.symbol("rm") do (i: In): + let vals = i.expect("'sym") + let v = vals[0] + let f = v.getString + if f.fileExists: + f.removeFile + else: + raiseInvalid("File '$1' does not exist." % f) + + def.symbol("cp") do (i: In): + let vals = i.expect("'sym", "'sym") + let a = vals[0] + let b = vals[1] + let src = b.getString + var dest = a.getString + if src.dirExists: + copyDirWithPermissions src, dest + elif dest.dirExists: + if src.dirExists: + copyDirWithPermissions src, dest + else: + copyFileWithPermissions src, dest / src.extractFilename + else: + copyFileWithPermissions src, dest + + def.symbol("mv") do (i: In): + let vals = i.expect("'sym", "'sym") + let a = vals[0] + let b = vals[1] + let src = b.getString + var dest = a.getString + if dest.dirExists: + dest = dest / src.extractFilename + moveFile src, dest + + def.symbol("rmdir") do (i: In): + let vals = i.expect("'sym") + let f = vals[0] + f.getString.removeDir + + def.symbol("mkdir") do (i: In): + let vals = i.expect("'sym") + let f = vals[0] + f.getString.createDir + + def.symbol("sleep") do (i: In): + let vals = i.expect("int") + let ms = vals[0] + sleep ms.intVal.int + + def.symbol("chmod") do (i: In): + let vals = i.expect("int", "string") + let perms = vals[0] + let s = vals[1] + s.getString.setFilePermissions(perms.intVal.toFilePermissions) + + def.symbol("symlink?") do (i: In): + let vals = i.expect("'sym") + let s = vals[0] + i.push s.getString.symlinkExists.newVal + + def.symbol("symlink") do (i: In): + let vals = i.expect("'sym", "'sym") + let dest = vals[0] + let src = vals[1] + src.getString.createSymlink dest.getString + + def.symbol("hardlink") do (i: In): + let vals = i.expect("'sym", "'sym") + let dest = vals[0] + let src = vals[1] + src.getString.createHardlink dest.getString + + def.symbol("filename") do (i: In): + let vals = i.expect("'sym") + let f = vals[0] + i.push f.getString.extractFilename.unix.newVal + + def.symbol("dirname") do (i: In): + let vals = i.expect("'sym") + let f = vals[0] + i.push f.getString.parentDir.unix.newVal + + def.symbol("$") do (i: In): + i.push("get-env".newSym) + + def.symbol("!") do (i: In): + i.push("system".newSym) + + def.symbol("!!") do (i: In): + i.push("system!".newSym) + + def.symbol("&") do (i: In): + i.push("run".newSym) + + def.sigil("$") do (i: In): + i.push("get-env".newSym) + + def.sigil("!") do (i: In): + i.push("system".newSym) + + def.sigil("&") do (i: In): + i.push("run".newSym) + + when not defined(lite): + def.symbol("unzip") do (i: In): + let vals = i.expect("'sym", "'sym") + let dir = vals[0] + let f = vals[1] + nim_miniz.unzip(f.getString, dir.getString) + + def.symbol("zip") do (i: In): + let vals = i.expect("'sym", "quot") + let file = vals[0] + let files = vals[1] + nim_miniz.zip(files.qVal.mapIt(it.getString), file.getString) + + def.finalize("sys") +
M
min.vim
→
min.vim
@@ -1,8 +1,8 @@
" Vim syntax file " Language: min " Maintainer: Fabio Cevasco -" Last Change: 07 Dec 2020 -" Version: 0.23.0 +" Last Change: 10 Dec 2020 +" Version: 0.24.0 if exists("b:current_syntax") finish@@ -11,7 +11,7 @@
setl iskeyword=@,36-39,+,-,*,.,/,:,~,!,48-57,60-65,94-95,192-255 setl iskeyword+=^ -syntax keyword minDefaultSymbol ! !! != # $ % & ' * + - -> -inf . .. / : < <= = =% == => =~ > >< >= >> @ ROOT ^ accept acos aes all? and any? append apply apply-interpolate args asin ask atan atime bind bool boolean? call capitalize case cd ceil chmod choose chr clear-stack cleave close column-print concat confirm connect cons cos cosh cp cpu crypto ctime d2r datetime ddel ddup debug decode define defined? delete dequote dequote-and dequote-or dget dhas? dict dictionary? dip dir? dirname div dkeys download dpairs dpick drop dset dtype dup dvalues e encode env? error escape eval even? exists? exit expect fappend fatal file? filename filter find first flatten float float? floor foreach format-error fperms fread from-json from-semver from-yaml fs fsize fstats ftype fwrite get get-content get-env get-stack getchr gets hardlink harvest hidden? http id if import in? indent indexof inf infix-dequote info insert int integer? interpolate io join keep last length linrec listen lite? ln load load-symbol log10 log2 logic loglevel loglevel? lowercase ls ls-r map map-reduce match math md5 mkdir mod module mtime mv nan net newline nip not notice now num number? odd? opts or ord os over parse partition password pi pick pop pow pred prefix prefix-dequote prepend print print! prompt publish put-env putchr puts puts! quit quotation? quote quote-bind quote-define quote-map r2g raise random randomize raw-args read recv recv-line reduce regex reject remove remove-symbol repeat replace request rest reverse rm rmdir rolldown rollup round run save-symbol saved-symbols scope scope-sigils scope-symbols seal search semver-inc-major semver-inc-minor semver-inc-patch semver? send seq set set-stack set-type sha1 sha224 sha256 sha384 sha512 shorten sigils sin sinh sip size sleep slice socket sort source split spread sqrt stack start-server stop-server str string string? strip substr succ suffix sum swap swons symbols symlink symlink? sys system system! take tan tanh tap tap! tau tformat time timeinfo times timestamp titleize to-json to-semver to-timestamp to-yaml trunc try type type? unless unseal unzip uppercase version warn when which while with xor zip +syntax keyword minDefaultSymbol ! !! != # $ % & ' * + - -> -inf . .. / : < <= = =% == => =~ > >< >= >> @ ROOT ^ accept acos aes all? and any? append apply apply-interpolate args asin ask atan atime bind bool boolean? call capitalize case cd ceil chmod choose chr clear-stack cleave close column-print compiled? concat confirm connect cons cos cosh cp cpu crypto ctime d2r datetime ddel ddup debug decode define defined? delete dequote dequote-and dequote-or dget dhas? dict dictionary? dip dir? dirname div dkeys download dpairs dpick drop dset dtype dup dvalues e encode env? error escape eval even? exists? exit expect fappend fatal file? filename filter find first flatten float float? floor foreach format-error fperms fread from-json from-semver from-yaml fs fsize fstats ftype fwrite get get-content get-env get-stack getchr gets hardlink harvest hidden? http id if import in? indent indexof inf infix-dequote info insert int integer? interpolate io join keep last length linrec listen lite? ln load load-symbol log10 log2 logic loglevel loglevel? lowercase ls ls-r map map-reduce match math md5 mini? mkdir mod module mtime mv nan net newline nip not notice now num number? odd? opts or ord os over parse partition password pi pick pop pow pred prefix prefix-dequote prepend print print! prompt publish put-env putchr puts puts! quit quotation? quote quote-bind quote-define quote-map r2g raise random randomize raw-args read recv recv-line reduce regex reject remove remove-symbol repeat replace request rest reverse rm rmdir rolldown rollup round run save-symbol saved-symbols scope scope-sigils scope-symbols seal search semver-inc-major semver-inc-minor semver-inc-patch semver? send seq set set-stack set-type sha1 sha224 sha256 sha384 sha512 shorten sigils sin sinh sip size sleep slice socket sort source split spread sqrt stack start-server stop-server str string string? strip substr succ suffix sum swap swons symbols symlink symlink? sys system system! take tan tanh tap tap! tau tformat time timeinfo times timestamp titleize to-json to-semver to-timestamp to-yaml trunc try type type? unless unseal unzip uppercase version warn when which while with xor zip syntax match minDefaultSigil ;\<[/:@'~!?$%&=<>#^*#+]; contained syntax match minQuote ;\<['];
M
tasks/build.min
→
tasks/build.min
@@ -82,7 +82,7 @@ "lite" "macosx" cz
) %macosx-lite ( "mini" "macosx" cz -) %macosx-min +) %macosx-mini ( "" "windows" cz ) %windows
M
tasks/release.min
→
tasks/release.min
@@ -20,8 +20,8 @@ build-tasks ^macosx-lite
build-tasks ^macosx-mini github-tasks ^update github-tasks ^upload - ssh-tasks ^build - ssh-tasks ^h3rald + ;ssh-tasks ^build + ;ssh-tasks ^h3rald "All done!" notice ) %default +release-tasks