diff options
Diffstat (limited to 'spec/fixtures/legacyexternalcommand.lua')
| -rw-r--r-- | spec/fixtures/legacyexternalcommand.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/fixtures/legacyexternalcommand.lua b/spec/fixtures/legacyexternalcommand.lua new file mode 100644 index 00000000..af575372 --- /dev/null +++ b/spec/fixtures/legacyexternalcommand.lua | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | |||
| 2 | --- Module implementing an external command with legacy arg parsing. | ||
| 3 | local legacyexternalcommand = {} | ||
| 4 | |||
| 5 | local util = require("luarocks.util") | ||
| 6 | |||
| 7 | legacyexternalcommand.help_summary = "generate legacyexternalcommand package files of a rock." | ||
| 8 | legacyexternalcommand.help_arguments = "arg1 [arg2]" | ||
| 9 | legacyexternalcommand.help = [[ | ||
| 10 | This addon generates legacyexternalcommand package files of a rock. | ||
| 11 | First argument is the name of a rock, the second argument is optional | ||
| 12 | and needed when legacyexternalcommand uses another name (usually prefixed by lua-). | ||
| 13 | Files are generated with the source content of the rock and more | ||
| 14 | especially the rockspec. So, the rock is downloaded and unpacked. | ||
| 15 | ]] | ||
| 16 | |||
| 17 | --- Driver function for the "legacyexternalcommand" command. | ||
| 18 | -- @param arg1 string: arg1. | ||
| 19 | -- @param arg2 string: arg2 (optional) | ||
| 20 | -- @return boolean: true if successful | ||
| 21 | function legacyexternalcommand.command(flags, arg1, arg2) | ||
| 22 | if type(arg1) ~= 'string' then | ||
| 23 | return nil, "Argument missing. "..util.see_help('legacyexternalcommand') | ||
| 24 | end | ||
| 25 | |||
| 26 | for k,v in pairs(flags) do | ||
| 27 | print("FLAGS", k,v) | ||
| 28 | end | ||
| 29 | print("ARG1", tostring(arg1)) | ||
| 30 | print("ARG2", tostring(arg2)) | ||
| 31 | return true | ||
| 32 | end | ||
| 33 | |||
| 34 | return legacyexternalcommand | ||
