From f52deeed485897511ecf80555e12a52c3e69d674 Mon Sep 17 00:00:00 2001 From: Paul Ouellette Date: Tue, 30 Jul 2019 16:08:48 -0400 Subject: Fix some failing tests --- spec/which_spec.lua | 2 +- src/luarocks/admin/cmd/add.lua | 3 ++- src/luarocks/cmd.lua | 30 ++++++++++++++++-------------- src/luarocks/cmd/build.lua | 5 +++++ src/luarocks/cmd/install.lua | 4 ++++ src/luarocks/cmd/make.lua | 9 +++++++-- src/luarocks/cmd/new_version.lua | 12 ++++++------ src/luarocks/cmd/purge.lua | 4 ++++ src/luarocks/cmd/show.lua | 2 +- 9 files changed, 46 insertions(+), 25 deletions(-) diff --git a/spec/which_spec.lua b/spec/which_spec.lua index d5bcfab9..79b9ef7e 100644 --- a/spec/which_spec.lua +++ b/spec/which_spec.lua @@ -22,7 +22,7 @@ describe("LuaRocks which tests #integration", function() it("fails on missing arguments", function() local output = run.luarocks("which") - assert.match("Missing module name", output, 1, true) + assert.match("missing argument 'modname'", output, 1, true) end) it("finds modules found in package.path", function() diff --git a/src/luarocks/admin/cmd/add.lua b/src/luarocks/admin/cmd/add.lua index 75f9386d..10e6bf09 100644 --- a/src/luarocks/admin/cmd/add.lua +++ b/src/luarocks/admin/cmd/add.lua @@ -20,6 +20,7 @@ function add.add_to_parser(parser) cmd:option("--server", "The server to use. If not given, the default server ".. "set in the upload_server variable from the configuration file is used instead.") + :target("add_server") cmd:flag("--no-refresh", "Do not refresh the local cache prior to ".. "generation of the updated manifest.") cmd:flag("--index", "Produce an index.html file for the manifest. This ".. @@ -125,7 +126,7 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do end function add.command(args) - local server, server_table = cache.get_upload_server(args.server) + local server, server_table = cache.get_upload_server(args.add_server or args.server) if not server then return nil, server_table end return add_files_to_server(not args.no_refresh, args.rock, server, server_table, args.index) end diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 174da616..0d249421 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua @@ -338,17 +338,10 @@ local function get_config_text(cfg) end local function get_parser(description, cmd_modules) - local epilog = [[ -Variables: - Variables from the "variables" table of the configuration file can be - overridden with VAR=VALUE assignments. - -]]..get_config_text(cfg) - local basename = dir.base_name(program) local parser = argparse( basename, "LuaRocks "..cfg.program_version..", the Lua package manager\n\n".. - program.." - "..description, epilog) + program.." - "..description) :help_max_width(80) :add_help("--help") :add_help_command() @@ -487,11 +480,6 @@ function cmd.run_command(description, commands, external_namespace, ...) local parser = get_parser(description, cmd_modules) args = parser:parse(args) - if not args.command then - util.printout(parser:get_help()) - os.exit(cmd.errorcodes.OK) - end - -- Compatibility for old flag if args.nodeps then args.deps_mode = "none" @@ -527,7 +515,7 @@ function cmd.run_command(description, commands, external_namespace, ...) if not lua_found then util.warning("Could not find a Lua " .. cfg.lua_version .. " interpreter in your PATH. " .. "Modules may not install with the correct configurations. " .. - "You may want to specify to the path prefix to your build " .. + "You may want to specify the path prefix to your build " .. "of Lua " .. cfg.lua_version .. " using --lua-dir") end cfg.lua_found = lua_found @@ -568,6 +556,20 @@ function cmd.run_command(description, commands, external_namespace, ...) cfg.local_cache = dir.path(fs.system_cache_dir(), "luarocks") end + parser:epilog([[ +Variables: + Variables from the "variables" table of the configuration file can be + overridden with VAR=VALUE assignments. + +]]..get_config_text(cfg)) + + if not args.command then + util.printout() + util.printout(parser:get_help()) + util.printout() + os.exit(cmd.errorcodes.OK) + end + local cmd_mod = cmd_modules[args.command] local call_ok, ok, err, exitcode = xpcall(function() return cmd_mod.command(args) diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index 09e0abc7..0b1864fc 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua @@ -25,6 +25,7 @@ function cmd_build.add_to_parser(parser) cmd:argument("rock", "A rockspec file, a source rock file, or the name of ".. "a rock to be fetched from a repository.") + :args("?") cmd:argument("version", "Rock version.") :args("?") @@ -33,6 +34,10 @@ function cmd_build.add_to_parser(parser) 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.') diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index 9085b3b7..6b308e0f 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua @@ -28,6 +28,10 @@ function install.add_to_parser(parser) 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:flag("--only-deps", "Installs only the dependencies of the rock.") cmd:flag("--no-doc", "Installs the rock without its documentation.") cmd:flag("--verify", "Verify signature of the rockspec or src.rock being ".. diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.lua index 512a3d74..da22a446 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.lua @@ -45,6 +45,10 @@ only dependencies of the rockspec (see `luarocks help install`). 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.') @@ -57,14 +61,15 @@ only dependencies of the rockspec (see `luarocks help install`). "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) end --- Driver function for "make" command. -- @return boolean or (nil, string, exitcode): True if build was successful; nil and an -- error message otherwise. exitcode is optionally returned. function make.command(args) - local rockspec - if not args.rockspec then + local rockspec = args.rockspec + if not rockspec then local err rockspec, err = util.get_default_rockspec() if not rockspec then diff --git a/src/luarocks/cmd/new_version.lua b/src/luarocks/cmd/new_version.lua index 95d762be..b6951059 100644 --- a/src/luarocks/cmd/new_version.lua +++ b/src/luarocks/cmd/new_version.lua @@ -139,22 +139,22 @@ local function update_source_section(out_rs, url, tag, old_ver, new_ver) end function new_version.command(args) - if not args.input then + if not args.rock then local err - args.input, err = util.get_default_rockspec() - if not args.input then + args.rock, err = util.get_default_rockspec() + if not args.rock then return nil, err end end local filename, err - if args.input:match("rockspec$") then - filename, err = fetch.fetch_url(args.input) + if args.rock:match("rockspec$") then + filename, err = fetch.fetch_url(args.rock) if not filename then return nil, err end else - filename, err = download.download("rockspec", args.input:lower()) + filename, err = download.download("rockspec", args.rock:lower()) if not filename then return nil, err end diff --git a/src/luarocks/cmd/purge.lua b/src/luarocks/cmd/purge.lua index bf037678..c9102876 100644 --- a/src/luarocks/cmd/purge.lua +++ b/src/luarocks/cmd/purge.lua @@ -29,6 +29,10 @@ The --tree option is mandatory: luarocks purge does not assume a default tree.]] "rock and remove the other ones. By default it only removes old ".. "versions if they are not needed as dependencies. This can be ".. "overridden with the flag --force.") + cmd:flag("--force", "If --old-versions is 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.") end function purge.command(args) diff --git a/src/luarocks/cmd/show.lua b/src/luarocks/cmd/show.lua index f599f443..dd4b33d1 100644 --- a/src/luarocks/cmd/show.lua +++ b/src/luarocks/cmd/show.lua @@ -262,7 +262,7 @@ end -- @return boolean: True if succeeded, nil on errors. function show.command(args) local name = util.adjust_name_and_namespace(args.rock, args) - local version = args.verson + local version = args.version local query = queries.new(name, version) local repo, repo_url -- cgit v1.2.3-55-g6feb