diff options
| -rw-r--r-- | src/luarocks/cmd.lua | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index eba5e9a8..093fe768 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
| @@ -11,7 +11,7 @@ local fun = require("luarocks.fun") | |||
| 11 | local fs = require("luarocks.fs") | 11 | local fs = require("luarocks.fs") |
| 12 | local argparse = require("luarocks.argparse") | 12 | local argparse = require("luarocks.argparse") |
| 13 | 13 | ||
| 14 | local unpack = unpack or table.unpack | 14 | local unpack = table.unpack or unpack |
| 15 | 15 | ||
| 16 | local hc_ok, hardcoded = pcall(require, "luarocks.core.hardcoded") | 16 | local hc_ok, hardcoded = pcall(require, "luarocks.core.hardcoded") |
| 17 | if not hc_ok then | 17 | if not hc_ok then |
| @@ -462,22 +462,21 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
| 462 | for name, module in pairs(commands) do | 462 | for name, module in pairs(commands) do |
| 463 | local pok, mod = pcall(require, module) | 463 | local pok, mod = pcall(require, module) |
| 464 | if pok and type(mod) == "table" then | 464 | if pok and type(mod) == "table" then |
| 465 | if not mod.add_to_parser then | 465 | local original_command = mod.command |
| 466 | mod.add_to_parser = function(parser) | 466 | if original_command then |
| 467 | parser:command(name, mod.help, util.see_also()) | 467 | if not mod.add_to_parser then |
| 468 | :summary(mod.help_summary) | 468 | mod.add_to_parser = function(parser) |
| 469 | :handle_options(false) | 469 | parser:command(name, mod.help, util.see_also()) |
| 470 | :argument("input") | 470 | :summary(mod.help_summary) |
| 471 | :args("*") | 471 | :handle_options(false) |
| 472 | end | 472 | :argument("input") |
| 473 | local original_command = mod.command | 473 | :args("*") |
| 474 | if original_command then | 474 | end |
| 475 | |||
| 475 | mod.command = function(args) | 476 | mod.command = function(args) |
| 476 | return original_command(args, unpack(args.input)) | 477 | return original_command(args, unpack(args.input)) |
| 477 | end | 478 | end |
| 478 | end | 479 | end |
| 479 | end | ||
| 480 | if mod.command then | ||
| 481 | cmd_modules[name] = mod | 480 | cmd_modules[name] = mod |
| 482 | else | 481 | else |
| 483 | util.warning("command module " .. module .. " does not implement command(), skipping") | 482 | util.warning("command module " .. module .. " does not implement command(), skipping") |
