mirror of
https://github.com/Hilbis/Hilbish
synced 2025-07-06 11:02:03 +00:00
Compare commits
No commits in common. "0ea0c15f702d7724d4e30a8dfbf2ce93c8a4d3ee" and "589ef8a6d3ec61e4a0cf3ca99cc810916e15eca7" have entirely different histories.
0ea0c15f70
...
589ef8a6d3
@ -204,6 +204,7 @@ func setupDocType(mod string, typ *doc.Type) *docPiece {
|
|||||||
}
|
}
|
||||||
|
|
||||||
typeTable[strings.ToLower(typeName)] = []string{parentMod, interfaces}
|
typeTable[strings.ToLower(typeName)] = []string{parentMod, interfaces}
|
||||||
|
println(typeName, parentMod, interfaces)
|
||||||
|
|
||||||
return dps
|
return dps
|
||||||
}
|
}
|
||||||
@ -436,8 +437,10 @@ provided by Hilbish.
|
|||||||
interfaceModules[modname].Types = append(interfaceModules[modname].Types, piece)
|
interfaceModules[modname].Types = append(interfaceModules[modname].Types, piece)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println(mod)
|
||||||
fmt.Println(filteredTypePieces)
|
fmt.Println(filteredTypePieces)
|
||||||
if newDoc, ok := docs[mod]; ok {
|
if newDoc, ok := docs[mod]; ok {
|
||||||
|
println("fuck")
|
||||||
oldMod := docs[mod]
|
oldMod := docs[mod]
|
||||||
newDoc.Types = append(filteredTypePieces, oldMod.Types...)
|
newDoc.Types = append(filteredTypePieces, oldMod.Types...)
|
||||||
newDoc.Docs = append(filteredPieces, oldMod.Docs...)
|
newDoc.Docs = append(filteredPieces, oldMod.Docs...)
|
||||||
|
@ -40,11 +40,6 @@ This function has no parameters.
|
|||||||
A Snail is a shell script interpreter instance.
|
A Snail is a shell script interpreter instance.
|
||||||
|
|
||||||
### Methods
|
### Methods
|
||||||
#### dir(path)
|
|
||||||
Changes the directory of the snail instance.
|
|
||||||
The interpreter keeps its set directory even when the Hilbish process changes
|
|
||||||
directory, so this should be called on the `hilbish.cd` hook.
|
|
||||||
|
|
||||||
#### run(command, streams)
|
#### run(command, streams)
|
||||||
Runs a shell command. Works the same as `hilbish.run`, but only accepts a table of streams.
|
Runs a shell command. Works the same as `hilbish.run`.
|
||||||
|
|
||||||
|
@ -2,15 +2,10 @@
|
|||||||
|
|
||||||
local snail = {}
|
local snail = {}
|
||||||
|
|
||||||
--- Changes the directory of the snail instance.
|
|
||||||
--- The interpreter keeps its set directory even when the Hilbish process changes
|
|
||||||
--- directory, so this should be called on the `hilbish.cd` hook.
|
|
||||||
function snail:dir(path) end
|
|
||||||
|
|
||||||
--- Creates a new Snail instance.
|
--- Creates a new Snail instance.
|
||||||
function snail.new() end
|
function snail.new() end
|
||||||
|
|
||||||
--- Runs a shell command. Works the same as `hilbish.run`, but only accepts a table of streams.
|
--- Runs a shell command. Works the same as `hilbish.run`.
|
||||||
function snail:run(command, streams) end
|
function snail:run(command, streams) end
|
||||||
|
|
||||||
return snail
|
return snail
|
||||||
|
@ -32,7 +32,6 @@ func loaderFunc(rtm *rt.Runtime) (rt.Value, func()) {
|
|||||||
snailMethods := rt.NewTable()
|
snailMethods := rt.NewTable()
|
||||||
snailFuncs := map[string]util.LuaExport{
|
snailFuncs := map[string]util.LuaExport{
|
||||||
"run": {snailrun, 3, false},
|
"run": {snailrun, 3, false},
|
||||||
"dir": {snaildir, 2, false},
|
|
||||||
}
|
}
|
||||||
util.SetExports(rtm, snailMethods, snailFuncs)
|
util.SetExports(rtm, snailMethods, snailFuncs)
|
||||||
|
|
||||||
@ -64,9 +63,7 @@ func snailnew(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||||||
|
|
||||||
// #member
|
// #member
|
||||||
// run(command, streams)
|
// run(command, streams)
|
||||||
// Runs a shell command. Works the same as `hilbish.run`, but only accepts a table of streams.
|
// Runs a shell command. Works the same as `hilbish.run`.
|
||||||
// #param command string
|
|
||||||
// #param streams table
|
|
||||||
func snailrun(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
func snailrun(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||||
if err := c.CheckNArgs(2); err != nil {
|
if err := c.CheckNArgs(2); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -95,7 +92,7 @@ func snailrun(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||||||
}
|
}
|
||||||
case rt.NilType: // noop
|
case rt.NilType: // noop
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("expected 3rd arg to be a table")
|
return nil, errors.New("expected 3rd arg to either be a table or a boolean")
|
||||||
}
|
}
|
||||||
|
|
||||||
var newline bool
|
var newline bool
|
||||||
@ -136,31 +133,6 @@ func snailrun(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||||||
return c.PushingNext1(t.Runtime, rt.TableValue(runnerRet)), nil
|
return c.PushingNext1(t.Runtime, rt.TableValue(runnerRet)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// #member
|
|
||||||
// dir(path)
|
|
||||||
// Changes the directory of the snail instance.
|
|
||||||
// The interpreter keeps its set directory even when the Hilbish process changes
|
|
||||||
// directory, so this should be called on the `hilbish.cd` hook.
|
|
||||||
// #param path string Has to be an absolute path.
|
|
||||||
func snaildir(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|
||||||
if err := c.CheckNArgs(2); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
s, err := snailArg(c, 0)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
dir, err := c.StringArg(1)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
interp.Dir(dir)(s.runner)
|
|
||||||
return c.Next(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleStream(v rt.Value, strms *util.Streams, errStream, inStream bool) error {
|
func handleStream(v rt.Value, strms *util.Streams, errStream, inStream bool) error {
|
||||||
if v == rt.NilValue {
|
if v == rt.NilValue {
|
||||||
return nil
|
return nil
|
||||||
|
@ -17,13 +17,11 @@ commander.register('cd', function (args, sinks)
|
|||||||
sinks.out:writeln(path)
|
sinks.out:writeln(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
local absPath = fs.abs(path)
|
|
||||||
local ok, err = pcall(function() fs.cd(path) end)
|
local ok, err = pcall(function() fs.cd(path) end)
|
||||||
if not ok then
|
if not ok then
|
||||||
sinks.out:writeln(err)
|
sinks.out:writeln(err)
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
bait.throw('cd', path, oldPath)
|
bait.throw('cd', path, oldPath)
|
||||||
bait.throw('hilbish.cd', absPath, oldPath)
|
bait.throw('hilbish.cd', fs.abs(path), oldPath)
|
||||||
end)
|
end)
|
||||||
|
@ -48,11 +48,11 @@ end
|
|||||||
--- @param dir string
|
--- @param dir string
|
||||||
function dirs.push(dir)
|
function dirs.push(dir)
|
||||||
dirs.recentDirs[dirs.recentSize + 1] = nil
|
dirs.recentDirs[dirs.recentSize + 1] = nil
|
||||||
if dirs.recentDirs[#dirs.recentDirs - 1] ~= dir then
|
if dirs.recentDirs[#dirs.recentDirs - 1] ~= d then
|
||||||
local ok, dir = pcall(fs.abs, dir)
|
ok, d = pcall(fs.abs, d)
|
||||||
assert(ok, 'could not turn "' .. dir .. '"into an absolute path')
|
assert(ok, 'could not turn "' .. d .. '"into an absolute path')
|
||||||
|
|
||||||
table.insert(dirs.recentDirs, 1, dir)
|
table.insert(dirs.recentDirs, 1, d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
-- @module hilbish
|
-- @module hilbish
|
||||||
local bait = require 'bait'
|
local hilbish = require 'hilbish'
|
||||||
local snail = require 'snail'
|
local snail = require 'snail'
|
||||||
|
|
||||||
hilbish.snail = snail.new()
|
hilbish.snail = snail.new()
|
||||||
bait.catch('hilbish.cd', function(path)
|
|
||||||
hilbish.snail:dir(path)
|
|
||||||
end)
|
|
||||||
--- Runs `cmd` in Hilbish's shell script interpreter.
|
--- Runs `cmd` in Hilbish's shell script interpreter.
|
||||||
--- The `streams` parameter specifies the output and input streams the command should use.
|
--- The `streams` parameter specifies the output and input streams the command should use.
|
||||||
--- For example, to write command output to a sink.
|
--- For example, to write command output to a sink.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user