From d394ecba0cb8572b60483e23444ce79a9761a1aa Mon Sep 17 00:00:00 2001 From: Paul Ouellette Date: Thu, 1 Aug 2019 21:25:59 -0400 Subject: Remove duplication between build and make commands --- src/luarocks/cmd/build.lua | 26 +++---------------------- src/luarocks/cmd/make.lua | 48 +++++++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index 0b1864fc..428ede2a 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua @@ -19,7 +19,8 @@ local make = require("luarocks.cmd.make") local cmd = require("luarocks.cmd") function cmd_build.add_to_parser(parser) - local cmd = parser:command("build", "Build and install a rock, compiling its C parts if any.", util.see_also()) + local cmd = parser:command("build", "Build and install a rock, compiling its C parts if any.\n".. + "If no arguments are given, behaves as luarocks make.", util.see_also()) :summary("Build/compile a rock.") :add_help("--help") @@ -29,29 +30,8 @@ function cmd_build.add_to_parser(parser) cmd:argument("version", "Rock version.") :args("?") - cmd:flag("--pack-binary-rock", "Do not install rock. Instead, produce a ".. - ".rock file with the contents of compilation in the current directory.") - cmd:flag("--keep", "Do not remove previously installed versions of the ".. - "rock after building a new one. This behavior can be made permanent by ".. - "setting keep_other_versions=true in the configuration file.") - cmd:flag("--force", "If --keep is not specified, force removal of ".. - "previously installed versions if it would break dependencies.") - cmd:flag("--force-fast", "Like --force, but performs a forced removal ".. - "without reporting dependency issues.") - cmd:option("--branch", "Override the `source.branch` field in the loaded ".. - "rockspec. Allows to specify a different branch to fetch. Particularly ".. - 'for "dev" rocks.') - :argname("") cmd:flag("--only-deps", "Installs only the dependencies of the rock.") - cmd:flag("--verify", "Verify signature of the rockspec or src.rock being ".. - "built. If the rockspec or src.rock is being downloaded, LuaRocks will ".. - "attempt to download the signature as well. Otherwise, the signature ".. - "file should be already available locally in the same directory.\n".. - "You need the signer’s public key in your local keyring for this ".. - "option to work properly.") - cmd:flag("--sign", "To be used with --pack-binary-rock. Also produce a ".. - "signature file for the generated .rock file.") - util.deps_mode_option(cmd) + make.cmd_options(cmd) end --- Build and install a rock. diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.lua index da22a446..bc7c2c60 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.lua @@ -16,6 +16,31 @@ local deps = require("luarocks.deps") local writer = require("luarocks.manif.writer") local cmd = require("luarocks.cmd") +function make.cmd_options(parser) + parser:flag("--pack-binary-rock", "Do not install rock. Instead, produce a ".. + ".rock file with the contents of compilation in the current directory.") + parser:flag("--keep", "Do not remove previously installed versions of the ".. + "rock after building a new one. This behavior can be made permanent by ".. + "setting keep_other_versions=true in the configuration file.") + parser:flag("--force", "If --keep is not specified, force removal of ".. + "previously installed versions if it would break dependencies.") + parser:flag("--force-fast", "Like --force, but performs a forced removal ".. + "without reporting dependency issues.") + parser:option("--branch", "Override the `source.branch` field in the loaded ".. + "rockspec. Allows to specify a different branch to fetch. Particularly ".. + 'for "dev" rocks.') + :argname("") + parser:flag("--verify", "Verify signature of the rockspec or src.rock being ".. + "built. If the rockspec or src.rock is being downloaded, LuaRocks will ".. + "attempt to download the signature as well. Otherwise, the signature ".. + "file should be already available locally in the same directory.\n".. + "You need the signer’s public key in your local keyring for this ".. + "option to work properly.") + parser:flag("--sign", "To be used with --pack-binary-rock. Also produce a ".. + "signature file for the generated .rock file.") + util.deps_mode_option(parser) +end + function make.add_to_parser(parser) local cmd = parser:command("make", [[ Builds sources in the current directory, but unlike "build", @@ -40,28 +65,7 @@ only dependencies of the rockspec (see `luarocks help install`). cmd:argument("rockspec", "Rockspec for the rock to build.") :args("?") - cmd:flag("--pack-binary-rock", "Do not install rock. Instead, produce a ".. - ".rock file with the contents of compilation in the current directory.") - cmd:flag("--keep", "Do not remove previously installed versions of the ".. - "rock after building a new one. This behavior can be made permanent by ".. - "setting keep_other_versions=true in the configuration file.") - cmd:flag("--force", "If --keep is not specified, force removal of ".. - "previously installed versions if it would break dependencies.") - cmd:flag("--force-fast", "Like --force, but performs a forced removal ".. - "without reporting dependency issues.") - cmd:option("--branch", "Override the `source.branch` field in the loaded ".. - "rockspec. Allows to specify a different branch to fetch. Particularly ".. - 'for "dev" rocks.') - :argname("") - cmd:flag("--verify", "Verify signature of the rockspec or src.rock being ".. - "built. If the rockspec or src.rock is being downloaded, LuaRocks will ".. - "attempt to download the signature as well. Otherwise, the signature ".. - "file should be already available locally in the same directory.\n".. - "You need the signer’s public key in your local keyring for this ".. - "option to work properly.") - cmd:flag("--sign", "To be used with --pack-binary-rock. Also produce a ".. - "signature file for the generated .rock file.") - util.deps_mode_option(cmd) + make.cmd_options(cmd) end --- Driver function for "make" command. -- cgit v1.2.3-55-g6feb