2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-05-12 07:13:23 +00:00

Compare commits

...

8 Commits

Author SHA1 Message Date
149d3244e0
Merge eded38c7b59447cff7598d6cd0d9ff89b501aaa6 into 36ce05e85a862f12b206a4a336fba94834f7372c 2024-11-30 23:49:20 +00:00
CelestialCrafter
36ce05e85a
fix: handle completion info check error ()
* fix: handle completion info check error
fixes 

* make changelog more descriptive
2024-11-22 20:20:43 -04:00
ac7c97442e
chore: bump for bugfix release 2024-11-04 06:54:09 -04:00
7fc3f4a569
chore: revert "chore: add 2.4 motd (work in progress)"
This reverts commit e6b88816fdb3a827ac09b1f7f2f2be178b3ca421.
2024-11-04 06:51:31 -04:00
dbb45a1947
chore: revert "chore: bump to 2.4"
This reverts commit db851cf4f833de11dc72fc20821919ff45028391.
2024-11-04 06:51:20 -04:00
3da150bb64
chore: merge 2024-11-03 23:24:32 -04:00
46968e632b
fix: bump golua (closes ) 2024-11-03 23:24:18 -04:00
eded38c7b5
feat: add completions for sudo 2023-12-02 12:35:12 -04:00
8 changed files with 92 additions and 9 deletions

@ -2,6 +2,10 @@
## Unreleased
### Fixed
- Skip over file and prevent panic if info cannot be retrieved during file completion (due to permission error or anything else)
## [2.3.3] - 2024-11-04
### Fixed
- Heredocs having issues
### Added
@ -780,7 +784,8 @@ This input for example will prompt for more input to complete:
First "stable" release of Hilbish.
[2.3.1]: https://github.com/Rosettea/Hilbish/compare/v2.3.1...v2.3.2
[2.3.3]: https://github.com/Rosettea/Hilbish/compare/v2.3.2...v2.3.3
[2.3.2]: https://github.com/Rosettea/Hilbish/compare/v2.3.1...v2.3.2
[2.3.1]: https://github.com/Rosettea/Hilbish/compare/v2.3.0...v2.3.1
[2.3.0]: https://github.com/Rosettea/Hilbish/compare/v2.2.3...v2.3.0
[2.2.3]: https://github.com/Rosettea/Hilbish/compare/v2.2.2...v2.2.3

@ -157,9 +157,12 @@ func matchPath(query string) ([]string, string) {
files, _ := os.ReadDir(path)
for _, entry := range files {
// should we handle errors here?
file, err := entry.Info()
if err == nil && file.Mode() & os.ModeSymlink != 0 {
if err != nil {
continue
}
if file.Mode() & os.ModeSymlink != 0 {
path, err := filepath.EvalSymlinks(filepath.Join(path, file.Name()))
if err == nil {
file, err = os.Lstat(path)

2
go.mod

@ -34,4 +34,4 @@ replace github.com/maxlandon/readline => ./readline
replace layeh.com/gopher-luar => github.com/layeh/gopher-luar v1.0.10
replace github.com/arnodel/golua => github.com/Rosettea/golua v0.0.0-20240427174124-d239074c1749
replace github.com/arnodel/golua => github.com/Rosettea/golua v0.0.0-20241104031959-5551ea280f23

4
go.sum

@ -1,5 +1,5 @@
github.com/Rosettea/golua v0.0.0-20240427174124-d239074c1749 h1:jIFnWBTsYw8s7RX7H2AOXjDVhWP3ol7OzUVaPN2KnGI=
github.com/Rosettea/golua v0.0.0-20240427174124-d239074c1749/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE=
github.com/Rosettea/golua v0.0.0-20241104031959-5551ea280f23 h1:mUZnT0gmDEmTkqXsbnDbuJ3CNil7DCOMiCQYgjbKIdI=
github.com/Rosettea/golua v0.0.0-20241104031959-5551ea280f23/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE=
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20240815163633-562273e09b73 h1:zTTUJqNnrF2qf4LgygN8Oae5Uxn6ewH0hA8jyTCHfXw=
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20240815163633-562273e09b73/go.mod h1:YZalN5H7WNQw3DGij6IvHsEhn5YMW7M2FCwG6gnfKy4=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=

@ -1,3 +1,23 @@
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.completions.' .. name)
end
end
function hilbish.completion.handler(line, pos)
if type(line) ~= 'string' then error '#1 must be a string' end
if type(pos) ~= 'number' then error '#2 must be a number' end

@ -0,0 +1,53 @@
local function curry(f)
return function (x) return function (y) return f(x,y) end end
end
local flags = {}
local function flag(f, description)
flags[f] = {description}
end
local addflag = curry(flag)
addflag '-A' 'Ask for password via askpass or $SUDO_ASKPASS'
addflag '-B' 'Ring the bell as part of the password prompt.'
hilbish.complete('command.sudo', function(query, ctx, fields)
table.remove(fields, 1)
local nonflags = table.filter(fields, function(v)
if v == '' then
return false
end
return v:match '^%-' == nil
end)
if #fields == 1 or #nonflags == 0 then
-- complete commands or sudo flags
if query:match ('^%-') then
local compFlags = {}
for flg, flgstuff in pairs(flags) do
if flg:match('^' .. query) then
compFlags[flg] = flgstuff
end
end
local compGroup = {
items = compFlags,
type = 'list'
}
return {compGroup}, query
end
local comps, pfx = hilbish.completion.bins(query, ctx, fields)
local compGroup = {
items = comps,
type = 'grid'
}
return {compGroup}, pfx
end
-- otherwise, get command flags
return hilbish.completion.call('command.' .. fields[2], query, ctx, fields)
end)

@ -2,7 +2,9 @@ local bait = require 'bait'
local lunacolors = require 'lunacolors'
hilbish.motd = [[
{magenta}Hilbish{reset} blooms in the {blue}midnight.{reset}
Wait ... {magenta}2.3{reset} is basically the same as {red}2.2?{reset}
Erm.. {blue}Ctrl-C works for Commanders,{reset} {cyan}and the sh runner has some fixes.{reset}
Just trust me bro, this is an important bug fix release. {red}- 🌺 sammyette{reset}
]]
bait.catch('hilbish.init', function()

@ -11,8 +11,8 @@ var (
// Version info
var (
ver = "v2.4.0"
releaseName = "Moonflower"
ver = "v2.3.3"
releaseName = "Alyssum"
gitCommit string
gitBranch string