2
2
鏡像自 https://github.com/Hilbis/Hilbish synced 2025-07-10 21:12:02 +00:00

feat(preload/cd): throw command hooks in cd command and add support for folders with spaces

This commit is contained in:
TorchedSammy 2021-03-31 13:46:22 -04:00
父節點 0987899144
當前提交 204d50d73c

查看文件

@ -5,17 +5,23 @@ local fs = require 'fs'
local commander = require 'commander' local commander = require 'commander'
local bait = require 'bait' local bait = require 'bait'
commander.register('cd', function (path) commander.register('cd', function (args)
if #path == 1 then bait.throw('cd', args)
local ok, err = pcall(function() fs.cd(path[1]) end) if #args > 0 then
local path = ''
for i = 1, #args do
path = path .. tostring(args[i]) .. ' '
end
local ok, err = pcall(function() fs.cd(path) end)
if not ok then if not ok then
if err == 1 then if err == 1 then
print('directory does not exist') print('directory does not exist')
end end
end bait.throw('command.fail', nil)
bait.throw('cd', path) else bait.throw('command.success', nil) end
return return
end end
fs.cd(os.getenv 'HOME') fs.cd(os.getenv 'HOME')
bait.throw('cd', path) bait.throw('command.success', nil)
end) end)