Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/busted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit" ] # , "luajit-openresty"
luaVersion: [ "5.5", "5.4", "5.3", "5.2", "5.1", "luajit" ] # , "luajit-openresty"
runs-on: ubuntu-24.04
steps:
- name: Checkout
Expand All @@ -30,7 +30,7 @@ jobs:
luarocks install busted
luarocks install dkjson
luarocks install inifile
${{ matrix.luaVersion != '5.4' && 'luarocks install yaml' || '' }} # https://github.com/lubyk/yaml/issues/7
luarocks install lyaml

- name: Replace system cliargs with self
run: |
Expand Down
8 changes: 6 additions & 2 deletions src/cliargs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

local core = require('cliargs.core')()
local unpack = _G.unpack or table.unpack -- luacheck: compat
local pack = table.pack or function(...) return { n = select('#', ...), ... } end -- luacheck: compat

local cli = setmetatable({},{ __index = core })

Expand All @@ -10,9 +11,12 @@ function cli:parse(arguments, no_cleanup)
cli:cleanup()
end

local out = { core.parse(self, arguments) }
-- `#` is undefined for a table with a nil hole (e.g. the `nil, err`
-- returned on a parsing error), so use pack/unpack's explicit `n`
-- instead of relying on the table's border to reconstruct the count.
local out = pack(core.parse(self, arguments))

return unpack(out)
return unpack(out, 1, out.n)
end

-- Clean up the entire module (unload the scripts) as it's expected to be
Expand Down
18 changes: 9 additions & 9 deletions src/cliargs/config_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,27 @@ return {

--- Load configuration from a YAML file.
---
--- Requires the "yaml"[1] module to be present on the system. Get it with:
--- Requires the "lyaml"[1] module to be present on the system. Get it with:
---
--- luarocks install yaml
--- luarocks install lyaml
---
--- [1] http://doc.lubyk.org/yaml.html
--- [1] https://github.com/gvvaughan/lyaml
from_yaml = function(filepath)
local src, config, err
local yaml = require 'yaml'
local src, err
local lyaml = require 'lyaml'

src, err = read_file(filepath)

if not src and err then
return nil, err
end

config, err = yaml.load(src)
local ok, config_or_err = pcall(lyaml.load, src)

if not config and err then
return nil, err
if not ok then
return nil, config_or_err
end

return config
return config_or_err
end
}
Loading