diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-17 23:37:20 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-17 23:37:26 -0700 |
| commit | 88df5c72a317cc011f221627a2c3082078237cc1 (patch) | |
| tree | a0e983d6aa356dbcd7ec2f71378c3b796e960ac3 /lib/os.nom | |
| parent | af441330ff7cfdc466281ce135ca7231ec54c499 (diff) | |
Updating lib to v2
Diffstat (limited to 'lib/os.nom')
| -rw-r--r-- | lib/os.nom | 38 |
1 files changed, 17 insertions, 21 deletions
@@ -1,33 +1,29 @@ -#!/usr/bin/env nomsu -V1 +#!/usr/bin/env nomsu -V2.2.4.3 # This file defines some actions that interact with the operating system and filesystem. use "core" - -action [path of Nomsu file %filename] - lua> ".." - for i,f in files.walk(\%filename) do return f end +action [path of Nomsu file %filename]: + lua> "for i,f in files.walk(\%filename) do return f end" barf "Could not find file: \%filename" -action [sh> %cmd] +action [sh> %cmd]: lua> ".." local result = io.popen(\%cmd) local contents = result:read("*a") result:close() return contents -action [read file %filename] - =lua "files.read(\%filename)" - -compile [for file %f in %path %body] to +action [read file %filename] (=lua "files.read(\%filename)") +compile [for file %f in %path %body] to (..) Lua ".." for i,\(%f as lua expr) in files.walk(\(%path as lua expr)) do \(%body as lua statements) - \(compile as: === next %f ===) + \(compile as (===next %f ===)) end - \(compile as: === stop %f ===) + \(compile as (===stop %f ===)) -compile [%expr for file %f in %path] to +compile [%expr for file %f in %path] to (..) Lua value ".." (function() local ret = list{} @@ -37,14 +33,14 @@ compile [%expr for file %f in %path] to return ret end)() -action [write to file %filename %text, to file %filename write %text, write %text to file %filename] - lua> ".." - local file = io.open(\%filename, 'w') - file:write(\%text) - file:close() +action [..] + write to file %filename %text, to file %filename write %text + write %text to file %filename +..: + lua> "local file = io.open(\%filename, 'w')\nfile:write(\%text)\nfile:close()" -action [line number of %pos in %str] +action [line number of %pos in %str] (..) =lua "files.get_line_number(\%str, \%pos)" - -action [line %line_num in %str] + +action [line %line_num in %str] (..) =lua "files.get_line(\%str, \%line_num)" |
