Skip to content

Commit

Permalink
Merge branch 'master' into unbounded-splats
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Dec 18, 2023
2 parents 9afba52 + 684a028 commit 2da9ecd
Show file tree
Hide file tree
Showing 30 changed files with 391 additions and 155 deletions.
4 changes: 0 additions & 4 deletions .env

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/busted.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Busted

on: [ push, pull_request ]

jobs:

busted:
strategy:
fail-fast: false
matrix:
luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit" ] # , "luajit-openresty"
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup ‘lua’
uses: leafo/gh-actions-lua@v10
with:
luaVersion: ${{ matrix.luaVersion }}

- name: Setup ‘luarocks’
uses: leafo/gh-actions-luarocks@v4

- name: Setup test dependencies
run: |
luarocks install --deps-only lua_cliargs-dev-1.rockspec
luarocks install busted
luarocks install dkjson
luarocks install inifile
${{ matrix.luaVersion != '5.4' && 'luarocks install yaml' || '' }} # https://github.com/lubyk/yaml/issues/7
- name: Replace system cliargs with self
run: |
luarocks remove --force lua_cliargs
luarocks make
- name: Run regression tests
# disable project-local path prefixes to force use of system installation
run: busted -v --lpath="" --cpath="" -Xoutput --color
34 changes: 34 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy

on: [ push, workflow_dispatch ]

jobs:

affected:
uses: lunarmodules/.github/.github/workflows/list_affected_rockspecs.yml@main

build:
needs: affected
if: ${{ needs.affected.outputs.rockspecs }}
uses: lunarmodules/.github/.github/workflows/test_build_rock.yml@main
with:
rockspecs: ${{ needs.affected.outputs.rockspecs }}

upload:
needs: [ affected, build ]
# Only run upload if:
# 1. We are on the canonical repository (no uploads from forks)
# 2. The current commit is either tagged or on the default branch (the workflow will upload dev/scm rockspecs any
# time they are touched, tagged ones whenever the edited rockspec and tag match)
# 3. Some rockspecs were changed — this implies the commit changing the rockspec is the same one that gets tagged
if: >-
${{
github.repository == 'lunarmodules/lua_cliargs' &&
( github.ref_name == 'master' || startsWith(github.ref, 'refs/tags/') ) &&
needs.affected.outputs.rockspecs
}}
uses: lunarmodules/.github/.github/workflows/upload_to_luarocks.yml@main
with:
rockspecs: ${{ needs.affected.outputs.rockspecs }}
secrets:
apikey: ${{ secrets.LUAROCKS_APIKEY }}
13 changes: 13 additions & 0 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Luacheck

on: [push, pull_request]

jobs:

luacheck:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Luacheck
uses: lunarmodules/luacheck@v1
3 changes: 3 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ cache = false
files["spec"] = {
std = "+busted"
}

ignore = { "211/_" }
exclude_files = { "examples" }
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .travis_setup.sh

This file was deleted.

8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# lua_cliargs

[![travis-ci status](https://secure.travis-ci.org/amireh/lua_cliargs.png)](http://travis-ci.org/#!/amireh/lua_cliargs/builds)
[![Luacheck](https://img.shields.io/github/actions/workflow/status/lunarmodules/lua_cliargs/luacheck.yml?branch=master&label=Luacheck&logo=Lua)](https://github.com/lunarmodules/lua_cliargs/actions?workflow=Luacheck)
[![Busted](https://img.shields.io/github/actions/workflow/status/lunarmodules/lua_cliargs/busted.yml?branch=master&label=Busted&logo=Lua)](https://github.com/lunarmodules/lua_cliargs/actions?workflow=Busted)

cliargs is a command-line argument parser for Lua. It supports several types of arguments:

Expand Down Expand Up @@ -134,6 +135,11 @@ cli:splat('MY_SPLAT', 'Description', nil, 1)
Also, the library internally had an arbitrary limit of 999 repetitions for the
splat argument. That limit has been relieved.

### 3.0-2

- optimized an internal routine responsible for word-wrapping. Thanks to
@Tieske, refs GH-47

### Changes from 2.5.x 3.0

This major version release contains BREAKING API CHANGES. See the UPGRADE guide for help in updating your code to make use of it.
Expand Down
2 changes: 1 addition & 1 deletion bin/lint
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ if [ ! -d src ]; then
exit 1
fi

luacheck .
luacheck --codes . $@
62 changes: 62 additions & 0 deletions lua_cliargs-dev-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
local package_name = "lua_cliargs"
local package_version = "dev"
local rockspec_revision = "1"
local github_account_name = "lunarmodules"
local github_repo_name = package_name

rockspec_format = "3.0"
package = package_name
version = package_version .. "-" .. rockspec_revision

source = {
url = "git+https://github.com/" .. github_account_name .. "/" .. github_repo_name .. ".git"
}
if package_version == "dev" then source.branch = "master" else source.tag = "v" .. package_version end

description = {
summary = "A command-line argument parsing module for Lua",
detailed = [[
This module adds support for accepting CLI arguments easily using multiple
notations and argument types.
cliargs allows you to define required, optional, and flag arguments.
]],
homepage = "https://github.com/"..github_account_name.."/"..github_repo_name,
issues_url = "https://github.com/"..github_account_name.."/"..github_repo_name.."/issues",
license = "MIT"
}

dependencies = {
"lua >= 5.1"
}

test_dependencies = {
"busted",
"dkjson",
"inifile",
"yaml",
}

test = {
type = "busted",
}

build = {
type = "builtin",
modules = {
["cliargs"] = "src/cliargs.lua",
["cliargs.config_loader"] = "src/cliargs/config_loader.lua",
["cliargs.constants"] = "src/cliargs/constants.lua",
["cliargs.core"] = "src/cliargs/core.lua",
["cliargs.parser"] = "src/cliargs/parser.lua",
["cliargs.printer"] = "src/cliargs/printer.lua",
["cliargs.utils.disect"] = "src/cliargs/utils/disect.lua",
["cliargs.utils.disect_argument"] = "src/cliargs/utils/disect_argument.lua",
["cliargs.utils.filter"] = "src/cliargs/utils/filter.lua",
["cliargs.utils.lookup"] = "src/cliargs/utils/lookup.lua",
["cliargs.utils.shallow_copy"] = "src/cliargs/utils/shallow_copy.lua",
["cliargs.utils.split"] = "src/cliargs/utils/split.lua",
["cliargs.utils.trim"] = "src/cliargs/utils/trim.lua",
["cliargs.utils.wordwrap"] = "src/cliargs/utils/wordwrap.lua",
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package = "lua_cliargs"
version = "3.0-1"
version = "3.0-2"
source = {
url = "https://github.com/amireh/lua_cliargs/archive/v3.0-1.tar.gz",
dir = "lua_cliargs-3.0-1"
url = "https://github.com/amireh/lua_cliargs/archive/v3.0-2.tar.gz",
dir = "lua_cliargs-3.0-2"
}
description = {
summary = "A command-line argument parser.",
Expand Down
48 changes: 48 additions & 0 deletions rockspecs/lua_cliargs-3.0.2-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
local package_name = "lua_cliargs"
local package_version = "3.0.2"
local rockspec_revision = "1"
local github_account_name = "lunarmodules"
local github_repo_name = package_name

package = package_name
version = package_version .. "-" .. rockspec_revision

source = {
url = "git+https://github.com/" .. github_account_name .. "/" .. github_repo_name .. ".git"
}
if package_version == "dev" then source.branch = "master" else source.tag = "v" .. package_version end

description = {
summary = "A command-line argument parsing module for Lua",
detailed = [[
This module adds support for accepting CLI arguments easily using multiple
notations and argument types.
cliargs allows you to define required, optional, and flag arguments.
]],
license = "MIT"
}

dependencies = {
"lua >= 5.1"
}

build = {
type = "builtin",
modules = {
["cliargs"] = "src/cliargs.lua",
["cliargs.config_loader"] = "src/cliargs/config_loader.lua",
["cliargs.constants"] = "src/cliargs/constants.lua",
["cliargs.core"] = "src/cliargs/core.lua",
["cliargs.parser"] = "src/cliargs/parser.lua",
["cliargs.printer"] = "src/cliargs/printer.lua",
["cliargs.utils.disect"] = "src/cliargs/utils/disect.lua",
["cliargs.utils.disect_argument"] = "src/cliargs/utils/disect_argument.lua",
["cliargs.utils.filter"] = "src/cliargs/utils/filter.lua",
["cliargs.utils.lookup"] = "src/cliargs/utils/lookup.lua",
["cliargs.utils.shallow_copy"] = "src/cliargs/utils/shallow_copy.lua",
["cliargs.utils.split"] = "src/cliargs/utils/split.lua",
["cliargs.utils.trim"] = "src/cliargs/utils/trim.lua",
["cliargs.utils.wordwrap"] = "src/cliargs/utils/wordwrap.lua",
}
}
4 changes: 2 additions & 2 deletions spec/cliargs_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
dofile("spec/spec_helper.lua")
local cliargs = require 'cliargs'

describe('cliargs', function()
Expand Down Expand Up @@ -63,4 +63,4 @@ describe('cliargs', function()
assert.is_nil(package.loaded['cliargs'])
end)
end)
end)
end)
15 changes: 10 additions & 5 deletions spec/config_loader_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
dofile("spec/spec_helper.lua")

describe("cliargs.config_loader", function()
local cli, args, err
Expand Down Expand Up @@ -39,14 +39,19 @@ describe("cliargs.config_loader", function()
end)

describe('#from_yaml', function()
it('works', function()
args, err = cli:parse({ '--config', 'spec/fixtures/config.yml' })
end)
-- Because it isn't easy to install on Lua 5.4, some environments can't run this test
-- https://github.com/lubyk/yaml/issues/7
local hasyaml = pcall(require, "yaml")
if hasyaml then
it('works', function()
args, err = cli:parse({ '--config', 'spec/fixtures/config.yml' })
end)
end
end)

describe('#from_lua', function()
it('works', function()
args, err = cli:parse({ '--config', 'spec/fixtures/config.lua' })
end)
end)
end)
end)
Loading

0 comments on commit 2da9ecd

Please sign in to comment.