application/octet-stream
•
1.36 KB
•
41 lines
; Nujel - Copyright (C) 2020-2021 - Benjamin Vincent Schulenburg
; This project uses the MIT license, a copy should be included under /LICENSE
[def test-context "Nujel Standalone"]
[defn help [i]
"Describe 10 functions at offset 1"
[when-not [int? i] [set! i [int i]]]
[for-each [map [symbol-table off 10] string]
[fn [l] [def desc [describe l]]
[pfmtln "{l} {desc}"]]]
[def sc [/ [symbol-count] 10]]
[pfmtln "Help page {i} of {sc}"]]
[defn file/eval [path environment]
"Evaluate a Nujel source file in the current context"
[when-not environment [set! environment root-closure]]
[for-in [form [read [file/read path]]]
[eval-in environment form]]]
[defn file/file? [filename]
[ref [file/stat filename] :regular-file?]]
[defn file/dir? [filename]
[ref [file/stat filename] :directory?]]
[defn directory/read-relative [path]
[map [directory/read path]
[fn [a]
[cat path "/" a]]]]
[defn directory/read-recursive [path]
[flatten [map [directory/read-relative path]
[fn [A] [if [file/dir? A]
[directory/read-recursive A]
A]]]]]
[defn popen/trim [cmd]
"Run CMD using popen and return the trimmed stdout"
[trim [cdr [popen cmd]]]]