diff options
| author | Paul Ouellette <oue.paul18@gmail.com> | 2019-06-19 21:14:31 -0400 |
|---|---|---|
| committer | Paul Ouellette <oue.paul18@gmail.com> | 2019-08-01 23:53:03 -0400 |
| commit | d1d7fda791c7134af48e06f09a742b4727a6893f (patch) | |
| tree | 1d2d5c7712e5050bc780d5d8e90c5ad4e9ff5758 | |
| parent | c6a7d4c4656fbf0d9026741e4749d44a9446040c (diff) | |
| download | luarocks-d1d7fda791c7134af48e06f09a742b4727a6893f.tar.gz luarocks-d1d7fda791c7134af48e06f09a742b4727a6893f.tar.bz2 luarocks-d1d7fda791c7134af48e06f09a742b4727a6893f.zip | |
Remove duplication between write_rockspec and init
| -rw-r--r-- | src/luarocks/cmd/init.lua | 16 | ||||
| -rw-r--r-- | src/luarocks/cmd/write_rockspec.lua | 46 |
2 files changed, 26 insertions, 36 deletions
diff --git a/src/luarocks/cmd/init.lua b/src/luarocks/cmd/init.lua index bb10eb79..fe74751b 100644 --- a/src/luarocks/cmd/init.lua +++ b/src/luarocks/cmd/init.lua | |||
| @@ -20,21 +20,7 @@ function init.add_to_parser(parser) | |||
| 20 | :args("?") | 20 | :args("?") |
| 21 | cmd:flag("--reset", "Delete .luarocks/config-5.x.lua and ./lua and generate new ones.") | 21 | cmd:flag("--reset", "Delete .luarocks/config-5.x.lua and ./lua and generate new ones.") |
| 22 | 22 | ||
| 23 | cmd:group("Options for specifying rockspec data", | 23 | cmd:group("Options for specifying rockspec data", write_rockspec.cmd_options(cmd)) |
| 24 | cmd:option("--license", 'A license string, such as "MIT/X11" or "GNU GPL v3".') | ||
| 25 | :argname("<string>"), | ||
| 26 | cmd:option("--summary", "A short one-line description summary.") | ||
| 27 | :argname("<txt>"), | ||
| 28 | cmd:option("--detailed", "A longer description string.") | ||
| 29 | :argname("<txt>"), | ||
| 30 | cmd:option("--homepage", "Project homepage.") | ||
| 31 | :argname("<url>"), | ||
| 32 | cmd:option("--lua-versions", "Supported Lua versions. Accepted values are ".. | ||
| 33 | '"5.1", "5.2", "5.3", "5.1,5.2", "5.2,5.3", or "5.1,5.2,5.3".'), | ||
| 34 | cmd:option("--rockspec-format", 'Rockspec format version, such as "1.0" or "1.1".') | ||
| 35 | :argname("<ver>"), | ||
| 36 | cmd:option("--lib", "A comma-separated list of libraries that C files need to link to.") | ||
| 37 | :argname("<libs>")) | ||
| 38 | end | 24 | end |
| 39 | 25 | ||
| 40 | local function write_gitignore(entries) | 26 | local function write_gitignore(entries) |
diff --git a/src/luarocks/cmd/write_rockspec.lua b/src/luarocks/cmd/write_rockspec.lua index 846aebd4..dbf71a14 100644 --- a/src/luarocks/cmd/write_rockspec.lua +++ b/src/luarocks/cmd/write_rockspec.lua | |||
| @@ -24,6 +24,30 @@ local lua_versions = { | |||
| 24 | "5.1,5.2,5.3,5.4" | 24 | "5.1,5.2,5.3,5.4" |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | function write_rockspec.cmd_options(parser) | ||
| 28 | return parser:option("--output", "Write the rockspec with the given filename.\n".. | ||
| 29 | "If not given, a file is written in the current directory with a ".. | ||
| 30 | "filename based on given name and version.") | ||
| 31 | :argname("<file>"), | ||
| 32 | parser:option("--license", 'A license string, such as "MIT/X11" or "GNU GPL v3".') | ||
| 33 | :argname("<string>"), | ||
| 34 | parser:option("--summary", "A short one-line description summary.") | ||
| 35 | :argname("<txt>"), | ||
| 36 | parser:option("--detailed", "A longer description string.") | ||
| 37 | :argname("<txt>"), | ||
| 38 | parser:option("--homepage", "Project homepage.") | ||
| 39 | :argname("<txt>"), | ||
| 40 | parser:option("--lua-versions", 'Supported Lua versions. Accepted values are: "'.. | ||
| 41 | table.concat(lua_versions, '", "')..'".') | ||
| 42 | :argname("<ver>") | ||
| 43 | :choices(lua_versions), | ||
| 44 | parser:option("--rockspec-format", 'Rockspec format version, such as "1.0" or "1.1".') | ||
| 45 | :argname("<ver>"), | ||
| 46 | parser:option("--tag", "Tag to use. Will attempt to extract version number from it."), | ||
| 47 | parser:option("--lib", "A comma-separated list of libraries that C files need to link to.") | ||
| 48 | :argname("<libs>") | ||
| 49 | end | ||
| 50 | |||
| 27 | function write_rockspec.add_to_parser(parser) | 51 | function write_rockspec.add_to_parser(parser) |
| 28 | local cmd = parser:command("write_rockspec", [[ | 52 | local cmd = parser:command("write_rockspec", [[ |
| 29 | This command writes an initial version of a rockspec file, | 53 | This command writes an initial version of a rockspec file, |
| @@ -48,27 +72,7 @@ rockspec, and is not guaranteed to be complete or correct. ]], util.see_also()) | |||
| 48 | cmd:argument("location", "URL or path to the rock sources.") | 72 | cmd:argument("location", "URL or path to the rock sources.") |
| 49 | :args("?") | 73 | :args("?") |
| 50 | 74 | ||
| 51 | cmd:option("--output", "Write the rockspec with the given filename.\n".. | 75 | write_rockspec.cmd_options(cmd) |
| 52 | "If not given, a file is written in the current directory with a ".. | ||
| 53 | "filename based on given name and version.") | ||
| 54 | :argname("<file>") | ||
| 55 | cmd:option("--license", 'A license string, such as "MIT/X11" or "GNU GPL v3".') | ||
| 56 | :argname("<string>") | ||
| 57 | cmd:option("--summary", "A short one-line description summary.") | ||
| 58 | :argname("<txt>") | ||
| 59 | cmd:option("--detailed", "A longer description string.") | ||
| 60 | :argname("<txt>") | ||
| 61 | cmd:option("--homepage", "Project homepage.") | ||
| 62 | :argname("<txt>") | ||
| 63 | cmd:option("--lua-versions", 'Supported Lua versions. Accepted values are: "'.. | ||
| 64 | table.concat(lua_versions, '", "')..'".') | ||
| 65 | :argname("<ver>") | ||
| 66 | :choices(lua_versions) | ||
| 67 | cmd:option("--rockspec-format", 'Rockspec format version, such as "1.0" or "1.1".') | ||
| 68 | :argname("<ver>") | ||
| 69 | cmd:option("--tag", "Tag to use. Will attempt to extract version number from it.") | ||
| 70 | cmd:option("--lib", "A comma-separated list of libraries that C files need to link to.") | ||
| 71 | :argname("<libs>") | ||
| 72 | end | 76 | end |
| 73 | 77 | ||
| 74 | local function open_file(name) | 78 | local function open_file(name) |
