Skip to content

Commit

Permalink
WIP: introduce argparse
Browse files Browse the repository at this point in the history
  • Loading branch information
teto committed Aug 19, 2024
1 parent 6cb1c96 commit 0735c8e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
39 changes: 37 additions & 2 deletions bin/rockspec-generator-cli.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
local json = require('dkjson')

json.decode(github_event_data)
local basename = 'toto'
local version = '0.1'
local argparse = require('argparse')
local parser = argparse([[rockspec-generator", "LuaRocks "..version..", the Lua package manager\n\n
' without any arguments to see the configuration.]])
:help_max_width(80)
:add_help_command()
:add_complete_command({
help_max_width = 100,
summary = 'Output a shell completion script.',
description = [[
Output a shell completion script.
Enabling completions for Bash:
Add the following line to your ~/.bashrc:
source <(]] .. basename .. [[ completion bash)
or save the completion script to the local completion directory:
]] .. basename .. [[ completion bash > ~/.local/share/bash-completion/completions/]] .. basename .. [[
]],
})
:command_target('command')
:require_command(false)

parser:flag('--version', 'Show version info and exit.'):action(function()
print('Program version:', version)
os.exit(0)
end)
parser:flag('--dev', 'Enable the sub-repositories in rocks servers for ' .. 'rockspecs of in-development versions.')
parser:option('--template', 'Rockspec-template'):argname('<template>'):hidden_name('--only-sources-from')
-- :handle_options(false)
parser:argument('package_name')
-- :args("*")

args = parser:parse(args)

package_name = arg[0]
dependencies = arg[1]
rockspect_template = arg[1]
rockspect_template = args.template
-- json.decode(github_event_data)

local rockspec = require('ltr.rockspec').generate(package_name, modrev, specrev, rockspec_template, {
ref_type = args.ref_type,
Expand Down
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
};

base-dependencies = with pkgs.lua51Packages; [
argparse
dkjson
luafilesystem
];
Expand Down Expand Up @@ -93,10 +94,10 @@
name = "luarocks-tag-release-devShell";
buildInputs =
(with pkgs; [
base-dependencies
lua-language-server
luarocks
luaPackages.dkjson
lua
])
++ self.checks.${system}.formatting.enabledPackages;
shellHook = ''
Expand Down

0 comments on commit 0735c8e

Please sign in to comment.