From d1d7fda791c7134af48e06f09a742b4727a6893f Mon Sep 17 00:00:00 2001 From: Paul Ouellette Date: Wed, 19 Jun 2019 21:14:31 -0400 Subject: Remove duplication between write_rockspec and init --- src/luarocks/cmd/init.lua | 16 +------------ src/luarocks/cmd/write_rockspec.lua | 46 ++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 36 deletions(-) (limited to 'src') 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) :args("?") cmd:flag("--reset", "Delete .luarocks/config-5.x.lua and ./lua and generate new ones.") - cmd:group("Options for specifying rockspec data", - cmd:option("--license", 'A license string, such as "MIT/X11" or "GNU GPL v3".') - :argname(""), - cmd:option("--summary", "A short one-line description summary.") - :argname(""), - cmd:option("--detailed", "A longer description string.") - :argname(""), - cmd:option("--homepage", "Project homepage.") - :argname(""), - cmd:option("--lua-versions", "Supported Lua versions. Accepted values are ".. - '"5.1", "5.2", "5.3", "5.1,5.2", "5.2,5.3", or "5.1,5.2,5.3".'), - cmd:option("--rockspec-format", 'Rockspec format version, such as "1.0" or "1.1".') - :argname(""), - cmd:option("--lib", "A comma-separated list of libraries that C files need to link to.") - :argname("")) + cmd:group("Options for specifying rockspec data", write_rockspec.cmd_options(cmd)) end 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 = { "5.1,5.2,5.3,5.4" } +function write_rockspec.cmd_options(parser) + return parser:option("--output", "Write the rockspec with the given filename.\n".. + "If not given, a file is written in the current directory with a ".. + "filename based on given name and version.") + :argname(""), + parser:option("--license", 'A license string, such as "MIT/X11" or "GNU GPL v3".') + :argname(""), + parser:option("--summary", "A short one-line description summary.") + :argname(""), + parser:option("--detailed", "A longer description string.") + :argname(""), + parser:option("--homepage", "Project homepage.") + :argname(""), + parser:option("--lua-versions", 'Supported Lua versions. Accepted values are: "'.. + table.concat(lua_versions, '", "')..'".') + :argname("") + :choices(lua_versions), + parser:option("--rockspec-format", 'Rockspec format version, such as "1.0" or "1.1".') + :argname(""), + parser:option("--tag", "Tag to use. Will attempt to extract version number from it."), + parser:option("--lib", "A comma-separated list of libraries that C files need to link to.") + :argname("") +end + function write_rockspec.add_to_parser(parser) local cmd = parser:command("write_rockspec", [[ 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()) cmd:argument("location", "URL or path to the rock sources.") :args("?") - cmd:option("--output", "Write the rockspec with the given filename.\n".. - "If not given, a file is written in the current directory with a ".. - "filename based on given name and version.") - :argname("") - cmd:option("--license", 'A license string, such as "MIT/X11" or "GNU GPL v3".') - :argname("") - cmd:option("--summary", "A short one-line description summary.") - :argname("") - cmd:option("--detailed", "A longer description string.") - :argname("") - cmd:option("--homepage", "Project homepage.") - :argname("") - cmd:option("--lua-versions", 'Supported Lua versions. Accepted values are: "'.. - table.concat(lua_versions, '", "')..'".') - :argname("") - :choices(lua_versions) - cmd:option("--rockspec-format", 'Rockspec format version, such as "1.0" or "1.1".') - :argname("") - cmd:option("--tag", "Tag to use. Will attempt to extract version number from it.") - cmd:option("--lib", "A comma-separated list of libraries that C files need to link to.") - :argname("") + write_rockspec.cmd_options(cmd) end local function open_file(name) -- cgit v1.2.3-55-g6feb