From 84270767f50a51c0b00a22a32a9843b6e6c1f2d6 Mon Sep 17 00:00:00 2001 From: Paul Ouellette Date: Wed, 19 Jun 2019 22:10:48 -0400 Subject: args["foo"] --> args.foo, flags --> args --- src/luarocks/admin/cmd/add.lua | 4 +- src/luarocks/admin/cmd/make_manifest.lua | 8 +-- src/luarocks/admin/cmd/refresh_cache.lua | 2 +- src/luarocks/admin/cmd/remove.lua | 4 +- src/luarocks/cmd.lua | 84 ++++++++++++++++---------------- src/luarocks/cmd/config.lua | 30 ++++++------ src/luarocks/cmd/doc.lua | 10 ++-- src/luarocks/cmd/download.lua | 12 ++--- src/luarocks/cmd/install.lua | 14 +++--- src/luarocks/cmd/list.lua | 14 +++--- src/luarocks/cmd/make.lua | 16 +++--- src/luarocks/cmd/pack.lua | 4 +- src/luarocks/cmd/path.lua | 12 ++--- src/luarocks/cmd/purge.lua | 8 +-- src/luarocks/cmd/remove.lua | 4 +- src/luarocks/cmd/search.lua | 10 ++-- src/luarocks/cmd/show.lua | 34 ++++++------- src/luarocks/cmd/test.lua | 4 +- src/luarocks/cmd/unpack.lua | 2 +- src/luarocks/cmd/upload.lua | 8 +-- src/luarocks/cmd/write_rockspec.lua | 34 ++++++------- src/luarocks/deps.lua | 6 +-- src/luarocks/fs/lua.lua | 6 +-- src/luarocks/upload/api.lua | 10 ++-- src/luarocks/util.lua | 16 +++--- 25 files changed, 178 insertions(+), 178 deletions(-) (limited to 'src') diff --git a/src/luarocks/admin/cmd/add.lua b/src/luarocks/admin/cmd/add.lua index ad16c232..f07b9fae 100644 --- a/src/luarocks/admin/cmd/add.lua +++ b/src/luarocks/admin/cmd/add.lua @@ -125,9 +125,9 @@ 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.server) if not server then return nil, server_table end - return add_files_to_server(not args["no_refresh"], files, server, server_table, args["index"]) + return add_files_to_server(not args.no_refresh, files, server, server_table, args.index) end diff --git a/src/luarocks/admin/cmd/make_manifest.lua b/src/luarocks/admin/cmd/make_manifest.lua index c7614ab5..840501ba 100644 --- a/src/luarocks/admin/cmd/make_manifest.lua +++ b/src/luarocks/admin/cmd/make_manifest.lua @@ -32,16 +32,16 @@ function make_manifest.command(args) util.printout("Making manifest for "..repo) - if repo:match("/lib/luarocks") and not args["local_tree"] then + if repo:match("/lib/luarocks") and not args.local_tree then util.warning("This looks like a local rocks tree, but you did not pass --local-tree.") end - local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args["local_tree"]) - if ok and not args["local_tree"] then + local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args.local_tree) + if ok and not args.local_tree then util.printout("Generating index.html for "..repo) index.make_index(repo) end - if args["local_tree"] then + if args.local_tree then for luaver in util.lua_versions() do fs.delete(dir.path(repo, "manifest-"..luaver)) end diff --git a/src/luarocks/admin/cmd/refresh_cache.lua b/src/luarocks/admin/cmd/refresh_cache.lua index ab0708ec..a5bdecb4 100644 --- a/src/luarocks/admin/cmd/refresh_cache.lua +++ b/src/luarocks/admin/cmd/refresh_cache.lua @@ -17,7 +17,7 @@ function refresh_cache.add_to_parser(parser) end function refresh_cache.command(args) - local server, upload_server = cache.get_upload_server(args["server"]) + local server, upload_server = cache.get_upload_server(args.server) if not server then return nil, upload_server end local download_url = cache.get_server_urls(server, upload_server) diff --git a/src/luarocks/admin/cmd/remove.lua b/src/luarocks/admin/cmd/remove.lua index 3fe70da6..b730ca51 100644 --- a/src/luarocks/admin/cmd/remove.lua +++ b/src/luarocks/admin/cmd/remove.lua @@ -80,9 +80,9 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve end function admin_remove.command(args) - local server, server_table = cache.get_upload_server(args["server"]) + local server, server_table = cache.get_upload_server(args.server) if not server then return nil, server_table end - return remove_files_from_server(not args["no_refresh"], files, server, server_table) + return remove_files_from_server(not args.no_refresh, files, server, server_table) end diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index d85661d8..f000e59e 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua @@ -39,11 +39,11 @@ local function check_popen() end end -local process_tree_flags +local process_tree_args do - local function replace_tree(flags, root, tree) + local function replace_tree(args, root, tree) root = dir.normalize(root) - flags["tree"] = root + args.tree = root path.use_tree(tree or root) end @@ -59,44 +59,44 @@ do cfg.deploy_lib_dir = cfg.deploy_lib_dir:gsub("/+$", "") end - process_tree_flags = function(flags, project_dir) + process_tree_args = function(args, project_dir) - if flags["global"] then + if args.global then cfg.local_by_default = false end - if flags["tree"] then + if args.tree then local named = false for _, tree in ipairs(cfg.rocks_trees) do - if type(tree) == "table" and flags["tree"] == tree.name then + if type(tree) == "table" and args.tree == tree.name then if not tree.root then return nil, "Configuration error: tree '"..tree.name.."' has no 'root' field." end - replace_tree(flags, tree.root, tree) + replace_tree(args, tree.root, tree) named = true break end end if not named then - local root_dir = fs.absolute_name(flags["tree"]) - replace_tree(flags, root_dir) + local root_dir = fs.absolute_name(args.tree) + replace_tree(args, root_dir) end - elseif flags["local"] then + elseif args["local"] then if not cfg.home_tree then return nil, "The --local flag is meant for operating in a user's home directory.\n".. "You are running as a superuser, which is intended for system-wide operation.\n".. "To force using the superuser's home, use --tree explicitly." else - replace_tree(flags, cfg.home_tree) + replace_tree(args, cfg.home_tree) end - elseif flags["project_tree"] then - local tree = flags["project_tree"] + elseif args.project_tree then + local tree = args.project_tree table.insert(cfg.rocks_trees, 1, { name = "project", root = tree } ) loader.load_rocks_trees() path.use_tree(tree) elseif cfg.local_by_default then if cfg.home_tree then - replace_tree(flags, cfg.home_tree) + replace_tree(args, cfg.home_tree) end elseif project_dir then local project_tree = project_dir .. "/lua_modules" @@ -117,26 +117,26 @@ do end end -local function process_server_flags(flags) - if flags["server"] then - local protocol, pathname = dir.split_url(flags["server"]) +local function process_server_args(args) + if args.server then + local protocol, pathname = dir.split_url(args.server) table.insert(cfg.rocks_servers, 1, protocol.."://"..pathname) end - if flags["dev"] then + if args.dev then local append_dev = function(s) return dir.path(s, "dev") end local dev_servers = fun.traverse(cfg.rocks_servers, append_dev) cfg.rocks_servers = fun.concat(dev_servers, cfg.rocks_servers) end - if flags["only_server"] then - if flags["dev"] then + if args.only_server then + if args.dev then return nil, "--only-server cannot be used with --dev" end - if flags["server"] then + if args.server then return nil, "--only-server cannot be used with --server" end - cfg.rocks_servers = { flags["only_server"] } + cfg.rocks_servers = { args.only_server } end return true @@ -172,7 +172,7 @@ end local init_config do - local detect_config_via_flags + local detect_config_via_args do local function find_project_dir(project_tree) if project_tree then @@ -191,7 +191,7 @@ do return nil end - local function find_default_lua_version(flags, project_dir) + local function find_default_lua_version(args, project_dir) if hardcoded.FORCE_CONFIG then return nil end @@ -210,7 +210,7 @@ do if mod then local pok, ver = pcall(mod) if pok and type(ver) == "string" and ver:match("%d+.%d+") then - if flags["verbose"] then + if args.verbose then util.printout("Defaulting to Lua " .. ver .. " based on " .. f .. " ...") end return ver @@ -228,13 +228,13 @@ do end) end - local function detect_lua_via_flags(flags, project_dir) - local lua_version = flags["lua_version"] - or find_default_lua_version(flags, project_dir) + local function detect_lua_via_args(args, project_dir) + local lua_version = args.lua_version + or find_default_lua_version(args, project_dir) or (project_dir and find_version_from_config(project_dir)) - if flags["lua_dir"] then - local detected, err = util.find_lua(flags["lua_dir"], lua_version) + if args.lua_dir then + local detected, err = util.find_lua(args.lua_dir, lua_version) if not detected then die(err) end @@ -262,14 +262,14 @@ do return {} end - detect_config_via_flags = function(flags) - local project_dir, given = find_project_dir(flags["project_tree"]) - local detected = detect_lua_via_flags(flags, project_dir) - if flags["lua_version"] then - detected.given_lua_version = flags["lua_version"] + detect_config_via_args = function(args) + local project_dir, given = find_project_dir(args.project_tree) + local detected = detect_lua_via_args(args, project_dir) + if args.lua_version then + detected.given_lua_version = args.lua_version end - if flags["lua_dir"] then - detected.given_lua_dir = flags["lua_dir"] + if args.lua_dir then + detected.given_lua_dir = args.lua_dir end if given then detected.given_project_dir = project_dir @@ -279,8 +279,8 @@ do end end - init_config = function(flags) - local detected = detect_config_via_flags(flags) + init_config = function(args) + local detected = detect_config_via_args(args) -- FIXME A quick hack for the experimental Windows build if os.getenv("LUAROCKS_CROSS_COMPILING") then @@ -513,12 +513,12 @@ function cmd.run_command(description, commands, external_namespace, ...) die("Current directory does not exist. Please run LuaRocks from an existing directory.") end - local ok, err = process_tree_flags(args, cfg.project_dir) + local ok, err = process_tree_args(args, cfg.project_dir) if not ok then die(err) end - ok, err = process_server_flags(args) + ok, err = process_server_args(args) if not ok then die(err) end diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua index 4f688a65..9177c50d 100644 --- a/src/luarocks/cmd/config.lua +++ b/src/luarocks/cmd/config.lua @@ -230,10 +230,10 @@ local function write_entries(keys, scope, do_unset) end end -local function get_scope(flags) - return flags["scope"] - or (flags["local"] and "user") - or (flags["project_tree"] and "project") +local function get_scope(args) + return args.scope + or (args["local"] and "user") + or (args.project_tree and "project") or (cfg.local_by_default and "user") or "system" end @@ -245,25 +245,25 @@ function config_cmd.command(args) deps.check_lua_libdir(cfg.variables) -- deprecated flags - if args["lua_incdir"] then + if args.lua_incdir then print(cfg.variables.LUA_INCDIR) return true end - if args["lua_libdir"] then + if args.lua_libdir then print(cfg.variables.LUA_LIBDIR) return true end - if args["lua_ver"] then + if args.lua_ver then print(cfg.lua_version) return true end - if args["system_config"] then + if args.system_config then return config_file(cfg.config_files.system) end - if args["user_config"] then + if args.user_config then return config_file(cfg.config_files.user) end - if args["rock_trees"] then + if args.rock_trees then for _, tree in ipairs(cfg.rocks_trees) do if type(tree) == "string" then util.printout(dir.normalize(tree)) @@ -298,21 +298,21 @@ function config_cmd.command(args) ["variables.LUA_LIBDIR"] = cfg.variables.LUA_LIBDIR, ["lua_interpreter"] = cfg.lua_interpreter, } - return write_entries(keys, scope, args["unset"]) + return write_entries(keys, scope, args.unset) end if args.key then - if args.value or args["unset"] then + if args.value or args.unset then local scope = get_scope(args) - return write_entries({ [args.key] = args.value }, scope, args["unset"]) + return write_entries({ [args.key] = args.value }, scope, args.unset) else - return print_entry(args.key, cfg, args["json"]) + return print_entry(args.key, cfg, args.json) end end local cleancfg = cleanup(cfg) - if args["json"] then + if args.json then return print_json(cleancfg) else print(persist.save_from_table_to_string(cleancfg)) diff --git a/src/luarocks/cmd/doc.lua b/src/luarocks/cmd/doc.lua index 94a1b548..a732795d 100644 --- a/src/luarocks/cmd/doc.lua +++ b/src/luarocks/cmd/doc.lua @@ -63,7 +63,7 @@ function doc.command(args) local name = util.adjust_name_and_namespace(args.rock, args) local version = args.version local query = queries.new(name, version) - local iname, iversion, repo = search.pick_installed_rock(query, args["tree"]) + local iname, iversion, repo = search.pick_installed_rock(query, args.tree) if not iname then util.printout(name..(version and " "..version or "").." is not installed. Looking for it in the rocks servers...") return try_to_open_homepage(name, version) @@ -74,7 +74,7 @@ function doc.command(args) if not rockspec then return nil,err end local descript = rockspec.description or {} - if args["home"] then + if args.home then return show_homepage(descript.homepage, name, version) end @@ -90,7 +90,7 @@ function doc.command(args) end end if not docdir then - if descript.homepage and not args["list"] then + if descript.homepage and not args.list then util.printout("Local documentation directory not found -- opening "..descript.homepage.." ...") fs.browser(descript.homepage) return true @@ -104,7 +104,7 @@ function doc.command(args) local extensions = { htmlpatt, "%.md$", "%.txt$", "%.textile$", "" } local basenames = { "index", "readme", "manual" } - local porcelain = args["porcelain"] + local porcelain = args.porcelain if #files > 0 then util.title("Documentation files for "..name.." "..version, porcelain) if porcelain then @@ -119,7 +119,7 @@ function doc.command(args) end end - if args["list"] then + if args.list then return true end diff --git a/src/luarocks/cmd/download.lua b/src/luarocks/cmd/download.lua index 2b09e764..76acc9a5 100644 --- a/src/luarocks/cmd/download.lua +++ b/src/luarocks/cmd/download.lua @@ -27,7 +27,7 @@ end -- @return boolean or (nil, string): true if successful or nil followed -- by an error message. function cmd_download.command(args) - if not args.name and not args["all"] then + if not args.name and not args.all then return nil, "Argument missing. "..util.see_help("download") end @@ -37,15 +37,15 @@ function cmd_download.command(args) local arch - if args["source"] then + if args.source then arch = "src" - elseif args["rockspec"] then + elseif args.rockspec then arch = "rockspec" - elseif args["arch"] then - arch = args["arch"] + elseif args.arch then + arch = args.arch end - local dl, err = download.download(arch, name:lower(), version, args["all"]) + local dl, err = download.download(arch, name:lower(), version, args.all) return dl and true, err end diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index 343bcfbe..9085b3b7 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua @@ -223,15 +223,15 @@ function install.command(args) elseif args.rock:match("%.rock$") then local deps_mode = deps.get_deps_mode(args) local opts = install.opts({ - namespace = args["namespace"], - keep = not not args["keep"], - force = not not args["force"], - force_fast = not not args["force_fast"], - no_doc = not not args["no_doc"], + namespace = args.namespace, + keep = not not args.keep, + force = not not args.force, + force_fast = not not args.force_fast, + no_doc = not not args.no_doc, deps_mode = deps_mode, - verify = not not args["verify"], + verify = not not args.verify, }) - if args["only_deps"] then + if args.only_deps then return install_rock_file_deps(args.rock, opts) else return install_rock_file(args.rock, opts) diff --git a/src/luarocks/cmd/list.lua b/src/luarocks/cmd/list.lua index 01555e89..3e275a0d 100644 --- a/src/luarocks/cmd/list.lua +++ b/src/luarocks/cmd/list.lua @@ -73,13 +73,13 @@ function list.command(args) local query = queries.new(args.filter and args.filter:lower() or "", args.version, true) local trees = cfg.rocks_trees local title = "Rocks installed for Lua "..cfg.lua_version - if args["tree"] then - trees = { args["tree"] } - title = title .. " in " .. args["tree"] + if args.tree then + trees = { args.tree } + title = title .. " in " .. args.tree end - if args["outdated"] then - return list_outdated(trees, query, args["porcelain"]) + if args.outdated then + return list_outdated(trees, query, args.porcelain) end local results = {} @@ -89,8 +89,8 @@ function list.command(args) util.warning(err) end end - util.title(title, args["porcelain"]) - search.print_result_tree(results, args["porcelain"]) + util.title(title, args.porcelain) + search.print_result_tree(results, args.porcelain) return true end diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.lua index 7ac9978a..512a3d74 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.lua @@ -87,17 +87,17 @@ function make.command(args) minimal_mode = true, deps_mode = deps.get_deps_mode(args), build_only_deps = false, - namespace = args["namespace"], - branch = not not args["branch"], - verify = not not args["verify"], + namespace = args.namespace, + branch = not not args.branch, + verify = not not args.verify, }) - if args["sign"] and not args["pack_binary_rock"] then + if args.sign and not args.pack_binary_rock then return nil, "In the make command, --sign is meant to be used only with --pack-binary-rock" end - if args["pack_binary_rock"] then - return pack.pack_binary_rock(name, rockspec.version, args["sign"], function() + if args.pack_binary_rock then + return pack.pack_binary_rock(name, rockspec.version, args.sign, function() return build.build_rockspec(rockspec, opts) end) else @@ -107,8 +107,8 @@ function make.command(args) if not ok then return nil, err end local name, version = ok, err - if (not args["keep"]) and not cfg.keep_other_versions then - local ok, err = remove.remove_other_versions(name, version, args["force"], args["force_fast"]) + if (not args.keep) and not cfg.keep_other_versions then + local ok, err = remove.remove_other_versions(name, version, args.force, args.force_fast) if not ok then util.printerr(err) end end diff --git a/src/luarocks/cmd/pack.lua b/src/luarocks/cmd/pack.lua index 28c39687..1f428546 100644 --- a/src/luarocks/cmd/pack.lua +++ b/src/luarocks/cmd/pack.lua @@ -30,9 +30,9 @@ function cmd_pack.command(args) else local name = util.adjust_name_and_namespace(args.rock, args) local query = queries.new(name, args.version) - file, err = pack.pack_installed_rock(query, args["tree"]) + file, err = pack.pack_installed_rock(query, args.tree) end - return pack.report_and_sign_local_file(file, err, args["sign"]) + return pack.report_and_sign_local_file(file, err, args.sign) end return cmd_pack diff --git a/src/luarocks/cmd/path.lua b/src/luarocks/cmd/path.lua index c65aca01..bdb1d2bc 100644 --- a/src/luarocks/cmd/path.lua +++ b/src/luarocks/cmd/path.lua @@ -32,21 +32,21 @@ end --- Driver function for "path" command. -- @return boolean This function always succeeds. function path_cmd.command(args) - local lr_path, lr_cpath, lr_bin = cfg.package_paths(args["tree"]) + local lr_path, lr_cpath, lr_bin = cfg.package_paths(args.tree) local path_sep = cfg.export_path_separator - if args["lr_path"] then + if args.lr_path then util.printout(util.cleanup_path(lr_path, ';', cfg.lua_version)) return true - elseif args["lr_cpath"] then + elseif args.lr_cpath then util.printout(util.cleanup_path(lr_cpath, ';', cfg.lua_version)) return true - elseif args["lr_bin"] then + elseif args.lr_bin then util.printout(util.cleanup_path(lr_bin, path_sep)) return true end - if args["append"] then + if args.append then lr_path = package.path .. ";" .. lr_path lr_cpath = package.cpath .. ";" .. lr_cpath lr_bin = os.getenv("PATH") .. path_sep .. lr_bin @@ -60,7 +60,7 @@ function path_cmd.command(args) util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version))) util.printout(fs.export_cmd(lcpath_var, util.cleanup_path(lr_cpath, ';', cfg.lua_version))) - if not args["no_bin"] then + if not args.no_bin then util.printout(fs.export_cmd("PATH", util.cleanup_path(lr_bin, path_sep))) end return true diff --git a/src/luarocks/cmd/purge.lua b/src/luarocks/cmd/purge.lua index 7bb6b4ec..bf037678 100644 --- a/src/luarocks/cmd/purge.lua +++ b/src/luarocks/cmd/purge.lua @@ -32,7 +32,7 @@ The --tree option is mandatory: luarocks purge does not assume a default tree.]] end function purge.command(args) - local tree = args["tree"] + local tree = args.tree if type(tree) ~= "string" then return nil, "The --tree argument is mandatory. "..util.see_help("purge") @@ -49,15 +49,15 @@ function purge.command(args) search.local_manifest_search(results, path.rocks_dir(tree), queries.all()) local sort = function(a,b) return vers.compare_versions(b,a) end - if args["old_versions"] then + if args.old_versions then sort = vers.compare_versions end for package, versions in util.sortedpairs(results) do for version, _ in util.sortedpairs(versions, sort) do - if args["old_versions"] then + if args.old_versions then util.printout("Keeping "..package.." "..version.."...") - local ok, err = remove.remove_other_versions(package, version, args["force"], args["force_fast"]) + local ok, err = remove.remove_other_versions(package, version, args.force, args.force_fast) if not ok then util.printerr(err) end diff --git a/src/luarocks/cmd/remove.lua b/src/luarocks/cmd/remove.lua index b78d61bd..492ea5bb 100644 --- a/src/luarocks/cmd/remove.lua +++ b/src/luarocks/cmd/remove.lua @@ -40,7 +40,7 @@ end function cmd_remove.command(args) local name = util.adjust_name_and_namespace(args.rock, args) - local deps_mode = args["deps_mode"] or cfg.deps_mode + local deps_mode = args.deps_mode or cfg.deps_mode local ok, err = fs.check_command_permissions(args) if not ok then return nil, err, cmd.errorcodes.PERMISSIONDENIED end @@ -60,7 +60,7 @@ function cmd_remove.command(args) return nil, "Could not find rock '"..name..(version and " "..version or "").."' in "..path.rocks_tree_to_string(cfg.root_dir) end - local ok, err = remove.remove_search_results(results, name, deps_mode, args["force"], args["force_fast"]) + local ok, err = remove.remove_search_results(results, name, deps_mode, args.force, args.force_fast) if not ok then return nil, err end diff --git a/src/luarocks/cmd/search.lua b/src/luarocks/cmd/search.lua index 8c735b22..37ec5272 100644 --- a/src/luarocks/cmd/search.lua +++ b/src/luarocks/cmd/search.lua @@ -57,25 +57,25 @@ function cmd_search.command(args) local name = util.adjust_name_and_namespace(args.name, args) - if args["all"] then + if args.all then name, args.version = "", nil end - if not args.name and not args["all"] then + if not args.name and not args.all then return nil, "Enter name and version or use --all. "..util.see_help("search") end local query = queries.new(name:lower(), args.version, true) local result_tree, err = search.search_repos(query) - local porcelain = args["porcelain"] + local porcelain = args.porcelain local full_name = name .. (args.version and " " .. args.version or "") util.title(full_name .. " - Search results for Lua "..cfg.lua_version..":", porcelain, "=") local sources, binaries = split_source_and_binary_results(result_tree) - if next(sources) and not args["binary"] then + if next(sources) and not args.binary then util.title("Rockspecs and source rocks:", porcelain) search.print_result_tree(sources, porcelain) end - if next(binaries) and not args["source"] then + if next(binaries) and not args.source then util.title("Binary and pure-Lua rocks:", porcelain) search.print_result_tree(binaries, porcelain) end diff --git a/src/luarocks/cmd/show.lua b/src/luarocks/cmd/show.lua index 3a7d86e0..f599f443 100644 --- a/src/luarocks/cmd/show.lua +++ b/src/luarocks/cmd/show.lua @@ -266,7 +266,7 @@ function show.command(args) local query = queries.new(name, version) local repo, repo_url - name, version, repo, repo_url = search.pick_installed_rock(query, args["tree"]) + name, version, repo, repo_url = search.pick_installed_rock(query, args.tree) if not name then return nil, version end @@ -282,32 +282,32 @@ function show.command(args) if not manifest then return nil,err end local minfo = manifest.repository[name][version][1] - if args["rock_tree"] then util.printout(tree) - elseif args["rock_namespace"] then util.printout(namespace) - elseif args["rock_dir"] then util.printout(directory) - elseif args["home"] then util.printout(descript.homepage) - elseif args["rock_license"] then util.printout(descript.license) - elseif args["issues"] then util.printout(descript.issues_url) - elseif args["labels"] then util.printout(descript.labels and table.concat(descript.labels, "\n")) - elseif args["modules"] then util.printout(keys_as_string(minfo.modules, "\n")) - elseif args["deps"] then + if args.rock_tree then util.printout(tree) + elseif args.rock_namespace then util.printout(namespace) + elseif args.rock_dir then util.printout(directory) + elseif args.home then util.printout(descript.homepage) + elseif args.rock_license then util.printout(descript.license) + elseif args.issues then util.printout(descript.issues_url) + elseif args.labels then util.printout(descript.labels and table.concat(descript.labels, "\n")) + elseif args.modules then util.printout(keys_as_string(minfo.modules, "\n")) + elseif args.deps then for _, dep in ipairs(rockspec.dependencies) do util.printout(tostring(dep)) end - elseif args["build_deps"] then + elseif args.build_deps then for _, dep in ipairs(rockspec.build_dependencies) do util.printout(tostring(dep)) end - elseif args["test_deps"] then + elseif args.test_deps then for _, dep in ipairs(rockspec.test_dependencies) do util.printout(tostring(dep)) end - elseif args["rockspec"] then util.printout(rockspec_file) - elseif args["mversion"] then util.printout(version) - elseif args["porcelain"] then - show_rock(porcelain_template, namespace, name, version, rockspec, repo, minfo, args["tree"]) + elseif args.rockspec then util.printout(rockspec_file) + elseif args.mversion then util.printout(version) + elseif args.porcelain then + show_rock(porcelain_template, namespace, name, version, rockspec, repo, minfo, args.tree) else - show_rock(friendly_template, namespace, name, version, rockspec, repo, minfo, args["tree"]) + show_rock(friendly_template, namespace, name, version, rockspec, repo, minfo, args.tree) end return true end diff --git a/src/luarocks/cmd/test.lua b/src/luarocks/cmd/test.lua index cef17f53..99be7f40 100644 --- a/src/luarocks/cmd/test.lua +++ b/src/luarocks/cmd/test.lua @@ -33,7 +33,7 @@ end function cmd_test.command(args) if args.rockspec and args.rockspec:match("rockspec$") then - return test.run_test_suite(args.rockspec, args["test_type"], args.args) + return test.run_test_suite(args.rockspec, args.test_type, args.args) end table.insert(args.args, 1, args.rockspec) @@ -43,7 +43,7 @@ function cmd_test.command(args) return nil, err end - return test.run_test_suite(rockspec, args["test_type"], args.args) + return test.run_test_suite(rockspec, args.test_type, args.args) end return cmd_test diff --git a/src/luarocks/cmd/unpack.lua b/src/luarocks/cmd/unpack.lua index b84b4166..46a438ba 100644 --- a/src/luarocks/cmd/unpack.lua +++ b/src/luarocks/cmd/unpack.lua @@ -162,7 +162,7 @@ function unpack.command(args) end end - return run_unpacker(url, args["force"]) + return run_unpacker(url, args.force) end return unpack diff --git a/src/luarocks/cmd/upload.lua b/src/luarocks/cmd/upload.lua index 44e2a830..f19f1e93 100644 --- a/src/luarocks/cmd/upload.lua +++ b/src/luarocks/cmd/upload.lua @@ -58,14 +58,14 @@ function upload.command(args) if not res.module then util.printout("Will create new module (" .. tostring(rockspec.package) .. ")") end - if res.version and not args["force"] then + if res.version and not args.force then return nil, "Revision "..rockspec.version.." already exists on the server. "..util.see_help("upload") end local sigfname local rock_sigfname - if args["sign"] then + if args.sign then sigfname, err = signing.sign_file(args.rockspec) if err then return nil, "Failed signing rockspec: " .. err @@ -74,13 +74,13 @@ function upload.command(args) end local rock_fname - if not args["skip_pack"] and not is_dev_version(rockspec.version) then + if not args.skip_pack and not is_dev_version(rockspec.version) then util.printout("Packing " .. tostring(rockspec.package)) rock_fname, err = pack.pack_source_rock(args.rockspec) if not rock_fname then return nil, err end - if args["sign"] then + if args.sign then rock_sigfname, err = signing.sign_file(rock_fname) if err then return nil, "Failed signing rock: " .. err diff --git a/src/luarocks/cmd/write_rockspec.lua b/src/luarocks/cmd/write_rockspec.lua index dbf71a14..3895a7f8 100644 --- a/src/luarocks/cmd/write_rockspec.lua +++ b/src/luarocks/cmd/write_rockspec.lua @@ -278,9 +278,9 @@ function write_rockspec.command(args) version = nil end - if args["tag"] then + if args.tag then if not version then - version = args["tag"]:gsub("^v", "") + version = args.tag:gsub("^v", "") end end @@ -305,27 +305,27 @@ function write_rockspec.command(args) end version = version or "dev" - local filename = args["output"] or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") + local filename = args.output or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") local url = detect_url(location) - local homepage = detect_homepage(url, args["homepage"]) + local homepage = detect_homepage(url, args.homepage) local rockspec, err = rockspecs.from_persisted_table(filename, { - rockspec_format = args["rockspec_format"], + rockspec_format = args.rockspec_format, package = name, version = version.."-1", source = { url = url, - tag = args["tag"], + tag = args.tag, }, description = { - summary = args["summary"] or "*** please specify description summary ***", - detailed = args["detailed"] or "*** please enter a detailed description ***", + summary = args.summary or "*** please specify description summary ***", + detailed = args.detailed or "*** please enter a detailed description ***", homepage = homepage, - license = args["license"] or "*** please specify a license ***", + license = args.license or "*** please specify a license ***", }, dependencies = { - lua_version_dep[args["lua_versions"]], + lua_version_dep[args.lua_versions], }, build = {}, }) @@ -342,7 +342,7 @@ function write_rockspec.command(args) rockspec.source.file = dir.base_name(location) if not dir.is_basic_protocol(rockspec.source.protocol) then if version ~= "dev" then - rockspec.source.tag = args["tag"] or "v" .. version + rockspec.source.tag = args.tag or "v" .. version end end rockspec.source.dir = nil @@ -364,10 +364,10 @@ function write_rockspec.command(args) end local libs = nil - if args["lib"] then + if args.lib then libs = {} rockspec.external_dependencies = {} - for lib in args["lib"]:gmatch("([^,]+)") do + for lib in args.lib:gmatch("([^,]+)") do table.insert(libs, lib) rockspec.external_dependencies[lib:upper()] = { library = lib @@ -378,13 +378,13 @@ function write_rockspec.command(args) local ok, err = fs.change_dir(local_dir) if not ok then return nil, "Failed reaching files from project - error entering directory "..local_dir end - if not (args["summary"] and args["detailed"]) then + if not (args.summary and args.detailed) then local summary, detailed = detect_description() - rockspec.description.summary = args["summary"] or summary - rockspec.description.detailed = args["detailed"] or detailed + rockspec.description.summary = args.summary or summary + rockspec.description.detailed = args.detailed or detailed end - if not args["license"] then + if not args.license then local license, fulltext = check_license() if license then rockspec.description.license = license diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 93148de3..7bce3dec 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua @@ -570,9 +570,9 @@ function deps.check_lua_libdir(vars) return nil, "Failed finding Lua library. You may need to configure LUA_LIBDIR.", "dependency" end -function deps.get_deps_mode(flags) - if flags["deps_mode"] then - return flags["deps_mode"] +function deps.get_deps_mode(args) + if args.deps_mode then + return args.deps_mode else return cfg.deps_mode end diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 56583676..6028a925 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -1092,10 +1092,10 @@ end --- Check if user has write permissions for the command. -- Assumes the configuration variables under cfg have been previously set up. --- @param flags table: the flags table passed to run() drivers. +-- @param args table: the args table passed to run() drivers. -- @return boolean or (boolean, string): true on success, false on failure, -- plus an error message. -function fs_lua.check_command_permissions(flags) +function fs_lua.check_command_permissions(args) local ok = true local err = "" for _, directory in ipairs { cfg.rocks_dir, cfg.deploy_lua_dir, cfg.deploy_bin_dir, cfg.deploy_lua_dir } do @@ -1124,7 +1124,7 @@ function fs_lua.check_command_permissions(flags) if ok then return true else - if flags["local"] or cfg.local_by_default then + if args["local"] or cfg.local_by_default then err = err .. " \n-- please check your permissions." else err = err .. " \n-- you may want to run as a privileged user or use your local tree with --local." diff --git a/src/luarocks/upload/api.lua b/src/luarocks/upload/api.lua index bd584d1a..a28b517a 100644 --- a/src/luarocks/upload/api.lua +++ b/src/luarocks/upload/api.lua @@ -245,20 +245,20 @@ end end -function api.new(flags) +function api.new(args) local self = {} setmetatable(self, { __index = Api }) self.config = self:load_config() or {} - self.config.server = flags["server"] or self.config.server or cfg.upload.server + self.config.server = args.server or self.config.server or cfg.upload.server self.config.version = self.config.version or cfg.upload.version - self.config.key = flags["temp_key"] or flags["api_key"] or self.config.key - self.debug = flags["debug"] + self.config.key = args.temp_key or args.api_key or self.config.key + self.debug = args.debug if not self.config.key then return nil, "You need an API key to upload rocks.\n" .. "Navigate to "..self.config.server.."/settings to get a key\n" .. "and then pass it through the --api-key= flag." end - if flags["api_key"] then + if args.api_key then self:save_config() end return self diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 635d3a97..5df2df51 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -338,13 +338,13 @@ function util.LQ(s) return ("%q"):format(s) end ---- Normalize the --namespace flag and the user/rock syntax for namespaces. --- If a namespace is given in user/rock syntax, update the --namespace flag; --- If a namespace is given in --namespace flag, update the user/rock syntax. +--- Normalize the --namespace option and the user/rock syntax for namespaces. +-- If a namespace is given in user/rock syntax, update the --namespace option; +-- If a namespace is given in --namespace option, update the user/rock syntax. -- In case of conflicts, the user/rock syntax takes precedence. -function util.adjust_name_and_namespace(ns_name, flags) +function util.adjust_name_and_namespace(ns_name, args) assert(type(ns_name) == "string" or not ns_name) - assert(type(flags) == "table") + assert(type(args) == "table") if not ns_name then return @@ -354,10 +354,10 @@ function util.adjust_name_and_namespace(ns_name, flags) local name, namespace = util.split_namespace(ns_name) if namespace then - flags["namespace"] = namespace + args.namespace = namespace end - if flags["namespace"] then - name = flags["namespace"] .. "/" .. name + if args.namespace then + name = args.namespace .. "/" .. name end return name:lower() end -- cgit v1.2.3-55-g6feb