Compare commits

...

2 Commits

Author SHA1 Message Date
TorchedSammy 959030f70d
refactor: automatically load all nature commands 2022-09-02 23:01:39 -04:00
TorchedSammy 59cec0ffa5
fix: call hinter for hint text handler 2022-09-02 22:19:30 -04:00
2 changed files with 20 additions and 9 deletions

View File

@ -1,8 +1,19 @@
-- Add command builtins
require 'nature.commands.cd'
require 'nature.commands.cdr'
require 'nature.commands.doc'
require 'nature.commands.exit'
require 'nature.commands.disown'
require 'nature.commands.fg'
require 'nature.commands.bg'
local fs = require 'fs'
-- explanation: this specific function gives to us info about
-- the currently running source. this includes a path to the
-- source file (info.source)
-- we will use that to automatically load all commands by reading
-- all the files in this dir and just requiring it.
local info = debug.getinfo(1)
local commandDir = fs.dir(info.source)
if commandDir == '.' then return end
local commands = fs.readdir(commandDir)
for _, command in ipairs(commands) do
local name = command:gsub('%.lua', '') -- chop off extension
if name ~= 'init' then
-- skip this file (for obvious reasons)
require('nature.commands.' .. name)
end
end

2
rl.go
View File

@ -55,7 +55,7 @@ func newLineReader(prompt string, noHist bool) *lineReader {
return []rune{}
}
retVal, err := rt.Call1(l.MainThread(), rt.FunctionValue(highlighter),
retVal, err := rt.Call1(l.MainThread(), rt.FunctionValue(hinter),
rt.StringValue(string(line)), rt.IntValue(int64(pos)))
if err != nil {
fmt.Println(err)