Skip to content
Merged
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
7 changes: 3 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ jobs:
- name: Install Lux
uses: lumen-oss/gh-actions-lux@v1
with:
# Using v0.25.3 for publish (not v0.18.8 used in tests)
# Reason: v0.18.8 has bugs with lx upload causing 400 errors
# The publish workflow doesn't run tests, so no busted/penlight issues
version: 0.25.3
# Using v0.28.0 for publish (consistent with all workflows)
# The busted/penlight dependency issues are resolved in v0.28.0
version: 0.28.0

- name: Install LuaRocks (for validation)
run: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
if: ${{ steps.release.outputs.release_created }}
uses: lumen-oss/gh-actions-lux@v1
with:
version: 0.25.3
# Using v0.28.0 for consistency with all workflows (busted/penlight issues resolved)
version: 0.28.0

- name: Install just
if: ${{ steps.release.outputs.release_created }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
- name: Install Lux
uses: lumen-oss/gh-actions-lux@v1
with:
# Pinned to v0.18.8 due to busted/penlight transitive dependency issues
# Using v0.28.0 (busted/penlight dependency issues resolved in lux-lib 0.8.0+)
# Previously pinned to v0.18.8 due to busted/penlight transitive dependency issues
# in newer versions (see lumen-oss/lux#722)
# The publish workflow uses v0.25.3 which doesn't have this issue
# because it doesn't run tests (no busted dependency)
version: 0.18.8
# All workflows now use v0.28.0 consistently
version: 0.28.0

- name: Install system dependencies
run: |
Expand Down Expand Up @@ -49,8 +49,8 @@ jobs:
- name: Install Lux
uses: lumen-oss/gh-actions-lux@v1
with:
# See comment in test job above for version pinning rationale
version: 0.18.8
# See comment in test job above for version upgrade rationale
version: 0.28.0

- name: Install just
run: |
Expand Down
154 changes: 154 additions & 0 deletions bin/spin.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#!/usr/bin/env -S lx lua
--- roda CLI entry point
-- Parses command-line arguments and runs a spinner for the given command.

-- Add local path for development
package.path = "./lua/?.lua;./lua/?/init.lua;" .. package.path
package.cpath = "./.build/?.so;" .. package.cpath

local argp = require("roda.argp")
local roda = require("roda")

local parser = argp:new({
name = "roda",
description = "Elegant terminal spinners for Lua. Wraps commands with visual feedback.",
epilog = "If no command is provided, roda will exit with status 0.",
})

parser:options({
{
short = "t",
long = "title",
description = "Text to display next to the spinner",
type = "string",
count_params = 1,
dest = "title",
},
{
long = "spinner",
description = "Spinner style to use (e.g., dots, line, arc)",
type = "string",
count_params = 1,
dest = "spinner",
},
{
long = "show-output",
description = "Display the command's stdout/stderr after it finishes",
type = "boolean",
count_params = 0,
dest = "show_output",
},
{
short = "c",
long = "color",
description = "Color of the spinner (e.g., cyan, green, yellow)",
type = "string",
count_params = 1,
dest = "color",
},
{
long = "prefix-text",
description = "Text before spinner",
type = "string",
count_params = 1,
dest = "prefix_text",
},
{
long = "suffix-text",
description = "Text after spinner text",
type = "string",
count_params = 1,
dest = "suffix_text",
},
{
short = "h",
long = "help",
description = "Show this help message",
type = "boolean",
count_params = 0,
dest = "help",
},
})

local function main(...)
local args = { ... }
if #args == 0 then
-- No arguments, exit 0 as per test expectation
os.exit(0)
end

local parsed, err = pcall(function()
return parser:parse(args)
end)

if not parsed then
io.stderr:write("error: " .. tostring(err) .. "\n")
os.exit(1)
end

local options = err -- result from pcall

if options.help then
parser:print_system_help()
os.exit(0)
end

-- Find the '--' separator
local separator_index = nil
for i, arg in ipairs(args) do
if arg == "--" then
separator_index = i
break
end
end

local command_args = {}
if separator_index then
for i = separator_index + 1, #args do
table.insert(command_args, args[i])
end
end

-- Build spinner options
local spinner_opts = {}
if options.title then
spinner_opts.text = options.title
end
if options.spinner then
spinner_opts.spinner = options.spinner
end
if options.color then
spinner_opts.color = options.color
end
if options.prefix_text then
spinner_opts.prefixText = options.prefix_text
end
if options.suffix_text then
spinner_opts.suffixText = options.suffix_text
end

local spinner = roda(spinner_opts)

if #command_args == 0 then
-- No command to execute, just exit (test 6)
os.exit(0)
end

local command = command_args[1]
local cmd_args = {}
for i = 2, #command_args do
table.insert(cmd_args, command_args[i])
end

spinner:execute(command, cmd_args)(function(exit_code, output)
if options.show_output and output and #output > 0 then
io.stdout:write(output)
io.stdout:flush()
end
os.exit(exit_code)
end)

roda.run()
end

main(...)
7 changes: 4 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ build-system: prep
[group('build')]
[private]
compile:
@echo {{ assert(path_exists("bin/spin.lua") == "true", "bin/spin.lua not found - CLI entry point missing") }}
@echo "Compiling standalone binary..."
cd lua && luastatic ../bin/spin.lua \
cd lua && lx --lua-version {{ lua_version }} exec -- luastatic ../bin/spin.lua \
roda/init.lua roda/spinners.lua roda/ansi.lua roda/symbols.lua roda/util.lua roda/argp.lua \
../{{ build_dir / 'libluv.a' }} ../{{ build_dir / 'libuv.a' }} ../{{ build_dir / 'libsystem.a' }} {{ lua_lib }} \
{{ build_dir / 'libluv.a' }} {{ build_dir / 'libuv.a' }} {{ build_dir / 'libsystem.a' }} {{ lua_lib }} \
-I{{ lua_include }} && \
mv spin.luastatic.c ../{{ build_dir }}/ && \
mv spin.luastatic.c {{ build_dir }}/ && \
cd .. && \
mv lua/spin roda

Expand Down
Loading