diff options
| author | Paul Ouellette <oue.paul18@gmail.com> | 2019-06-19 22:10:48 -0400 |
|---|---|---|
| committer | Paul Ouellette <oue.paul18@gmail.com> | 2019-08-01 23:53:03 -0400 |
| commit | 84270767f50a51c0b00a22a32a9843b6e6c1f2d6 (patch) | |
| tree | 1cb4256bfd4c6d12062be3c88794553e04bb2f4f | |
| parent | 6fc92e343d6ea1db91bcb6c8e471b2442a8b5f43 (diff) | |
| download | luarocks-84270767f50a51c0b00a22a32a9843b6e6c1f2d6.tar.gz luarocks-84270767f50a51c0b00a22a32a9843b6e6c1f2d6.tar.bz2 luarocks-84270767f50a51c0b00a22a32a9843b6e6c1f2d6.zip | |
args["foo"] --> args.foo, flags --> args
| -rw-r--r-- | src/luarocks/admin/cmd/add.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/admin/cmd/make_manifest.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/admin/cmd/refresh_cache.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/admin/cmd/remove.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/cmd.lua | 84 | ||||
| -rw-r--r-- | src/luarocks/cmd/config.lua | 30 | ||||
| -rw-r--r-- | src/luarocks/cmd/doc.lua | 10 | ||||
| -rw-r--r-- | src/luarocks/cmd/download.lua | 12 | ||||
| -rw-r--r-- | src/luarocks/cmd/install.lua | 14 | ||||
| -rw-r--r-- | src/luarocks/cmd/list.lua | 14 | ||||
| -rw-r--r-- | src/luarocks/cmd/make.lua | 16 | ||||
| -rw-r--r-- | src/luarocks/cmd/pack.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/cmd/path.lua | 12 | ||||
| -rw-r--r-- | src/luarocks/cmd/purge.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/cmd/remove.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/cmd/search.lua | 10 | ||||
| -rw-r--r-- | src/luarocks/cmd/show.lua | 34 | ||||
| -rw-r--r-- | src/luarocks/cmd/test.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/cmd/unpack.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/cmd/upload.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/cmd/write_rockspec.lua | 34 | ||||
| -rw-r--r-- | src/luarocks/deps.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/fs/lua.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/upload/api.lua | 10 | ||||
| -rw-r--r-- | src/luarocks/util.lua | 16 |
25 files changed, 178 insertions, 178 deletions
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 | |||
| 125 | end | 125 | end |
| 126 | 126 | ||
| 127 | function add.command(args) | 127 | function add.command(args) |
| 128 | local server, server_table = cache.get_upload_server(args["server"]) | 128 | local server, server_table = cache.get_upload_server(args.server) |
| 129 | if not server then return nil, server_table end | 129 | if not server then return nil, server_table end |
| 130 | return add_files_to_server(not args["no_refresh"], files, server, server_table, args["index"]) | 130 | return add_files_to_server(not args.no_refresh, files, server, server_table, args.index) |
| 131 | end | 131 | end |
| 132 | 132 | ||
| 133 | 133 | ||
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) | |||
| 32 | 32 | ||
| 33 | util.printout("Making manifest for "..repo) | 33 | util.printout("Making manifest for "..repo) |
| 34 | 34 | ||
| 35 | if repo:match("/lib/luarocks") and not args["local_tree"] then | 35 | if repo:match("/lib/luarocks") and not args.local_tree then |
| 36 | util.warning("This looks like a local rocks tree, but you did not pass --local-tree.") | 36 | util.warning("This looks like a local rocks tree, but you did not pass --local-tree.") |
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args["local_tree"]) | 39 | local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args.local_tree) |
| 40 | if ok and not args["local_tree"] then | 40 | if ok and not args.local_tree then |
| 41 | util.printout("Generating index.html for "..repo) | 41 | util.printout("Generating index.html for "..repo) |
| 42 | index.make_index(repo) | 42 | index.make_index(repo) |
| 43 | end | 43 | end |
| 44 | if args["local_tree"] then | 44 | if args.local_tree then |
| 45 | for luaver in util.lua_versions() do | 45 | for luaver in util.lua_versions() do |
| 46 | fs.delete(dir.path(repo, "manifest-"..luaver)) | 46 | fs.delete(dir.path(repo, "manifest-"..luaver)) |
| 47 | end | 47 | 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) | |||
| 17 | end | 17 | end |
| 18 | 18 | ||
| 19 | function refresh_cache.command(args) | 19 | function refresh_cache.command(args) |
| 20 | local server, upload_server = cache.get_upload_server(args["server"]) | 20 | local server, upload_server = cache.get_upload_server(args.server) |
| 21 | if not server then return nil, upload_server end | 21 | if not server then return nil, upload_server end |
| 22 | local download_url = cache.get_server_urls(server, upload_server) | 22 | local download_url = cache.get_server_urls(server, upload_server) |
| 23 | 23 | ||
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 | |||
| 80 | end | 80 | end |
| 81 | 81 | ||
| 82 | function admin_remove.command(args) | 82 | function admin_remove.command(args) |
| 83 | local server, server_table = cache.get_upload_server(args["server"]) | 83 | local server, server_table = cache.get_upload_server(args.server) |
| 84 | if not server then return nil, server_table end | 84 | if not server then return nil, server_table end |
| 85 | return remove_files_from_server(not args["no_refresh"], files, server, server_table) | 85 | return remove_files_from_server(not args.no_refresh, files, server, server_table) |
| 86 | end | 86 | end |
| 87 | 87 | ||
| 88 | 88 | ||
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() | |||
| 39 | end | 39 | end |
| 40 | end | 40 | end |
| 41 | 41 | ||
| 42 | local process_tree_flags | 42 | local process_tree_args |
| 43 | do | 43 | do |
| 44 | local function replace_tree(flags, root, tree) | 44 | local function replace_tree(args, root, tree) |
| 45 | root = dir.normalize(root) | 45 | root = dir.normalize(root) |
| 46 | flags["tree"] = root | 46 | args.tree = root |
| 47 | path.use_tree(tree or root) | 47 | path.use_tree(tree or root) |
| 48 | end | 48 | end |
| 49 | 49 | ||
| @@ -59,44 +59,44 @@ do | |||
| 59 | cfg.deploy_lib_dir = cfg.deploy_lib_dir:gsub("/+$", "") | 59 | cfg.deploy_lib_dir = cfg.deploy_lib_dir:gsub("/+$", "") |
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | process_tree_flags = function(flags, project_dir) | 62 | process_tree_args = function(args, project_dir) |
| 63 | 63 | ||
| 64 | if flags["global"] then | 64 | if args.global then |
| 65 | cfg.local_by_default = false | 65 | cfg.local_by_default = false |
| 66 | end | 66 | end |
| 67 | 67 | ||
| 68 | if flags["tree"] then | 68 | if args.tree then |
| 69 | local named = false | 69 | local named = false |
| 70 | for _, tree in ipairs(cfg.rocks_trees) do | 70 | for _, tree in ipairs(cfg.rocks_trees) do |
| 71 | if type(tree) == "table" and flags["tree"] == tree.name then | 71 | if type(tree) == "table" and args.tree == tree.name then |
| 72 | if not tree.root then | 72 | if not tree.root then |
| 73 | return nil, "Configuration error: tree '"..tree.name.."' has no 'root' field." | 73 | return nil, "Configuration error: tree '"..tree.name.."' has no 'root' field." |
| 74 | end | 74 | end |
| 75 | replace_tree(flags, tree.root, tree) | 75 | replace_tree(args, tree.root, tree) |
| 76 | named = true | 76 | named = true |
| 77 | break | 77 | break |
| 78 | end | 78 | end |
| 79 | end | 79 | end |
| 80 | if not named then | 80 | if not named then |
| 81 | local root_dir = fs.absolute_name(flags["tree"]) | 81 | local root_dir = fs.absolute_name(args.tree) |
| 82 | replace_tree(flags, root_dir) | 82 | replace_tree(args, root_dir) |
| 83 | end | 83 | end |
| 84 | elseif flags["local"] then | 84 | elseif args["local"] then |
| 85 | if not cfg.home_tree then | 85 | if not cfg.home_tree then |
| 86 | return nil, "The --local flag is meant for operating in a user's home directory.\n".. | 86 | return nil, "The --local flag is meant for operating in a user's home directory.\n".. |
| 87 | "You are running as a superuser, which is intended for system-wide operation.\n".. | 87 | "You are running as a superuser, which is intended for system-wide operation.\n".. |
| 88 | "To force using the superuser's home, use --tree explicitly." | 88 | "To force using the superuser's home, use --tree explicitly." |
| 89 | else | 89 | else |
| 90 | replace_tree(flags, cfg.home_tree) | 90 | replace_tree(args, cfg.home_tree) |
| 91 | end | 91 | end |
| 92 | elseif flags["project_tree"] then | 92 | elseif args.project_tree then |
| 93 | local tree = flags["project_tree"] | 93 | local tree = args.project_tree |
| 94 | table.insert(cfg.rocks_trees, 1, { name = "project", root = tree } ) | 94 | table.insert(cfg.rocks_trees, 1, { name = "project", root = tree } ) |
| 95 | loader.load_rocks_trees() | 95 | loader.load_rocks_trees() |
| 96 | path.use_tree(tree) | 96 | path.use_tree(tree) |
| 97 | elseif cfg.local_by_default then | 97 | elseif cfg.local_by_default then |
| 98 | if cfg.home_tree then | 98 | if cfg.home_tree then |
| 99 | replace_tree(flags, cfg.home_tree) | 99 | replace_tree(args, cfg.home_tree) |
| 100 | end | 100 | end |
| 101 | elseif project_dir then | 101 | elseif project_dir then |
| 102 | local project_tree = project_dir .. "/lua_modules" | 102 | local project_tree = project_dir .. "/lua_modules" |
| @@ -117,26 +117,26 @@ do | |||
| 117 | end | 117 | end |
| 118 | end | 118 | end |
| 119 | 119 | ||
| 120 | local function process_server_flags(flags) | 120 | local function process_server_args(args) |
| 121 | if flags["server"] then | 121 | if args.server then |
| 122 | local protocol, pathname = dir.split_url(flags["server"]) | 122 | local protocol, pathname = dir.split_url(args.server) |
| 123 | table.insert(cfg.rocks_servers, 1, protocol.."://"..pathname) | 123 | table.insert(cfg.rocks_servers, 1, protocol.."://"..pathname) |
| 124 | end | 124 | end |
| 125 | 125 | ||
| 126 | if flags["dev"] then | 126 | if args.dev then |
| 127 | local append_dev = function(s) return dir.path(s, "dev") end | 127 | local append_dev = function(s) return dir.path(s, "dev") end |
| 128 | local dev_servers = fun.traverse(cfg.rocks_servers, append_dev) | 128 | local dev_servers = fun.traverse(cfg.rocks_servers, append_dev) |
| 129 | cfg.rocks_servers = fun.concat(dev_servers, cfg.rocks_servers) | 129 | cfg.rocks_servers = fun.concat(dev_servers, cfg.rocks_servers) |
| 130 | end | 130 | end |
| 131 | 131 | ||
| 132 | if flags["only_server"] then | 132 | if args.only_server then |
| 133 | if flags["dev"] then | 133 | if args.dev then |
| 134 | return nil, "--only-server cannot be used with --dev" | 134 | return nil, "--only-server cannot be used with --dev" |
| 135 | end | 135 | end |
| 136 | if flags["server"] then | 136 | if args.server then |
| 137 | return nil, "--only-server cannot be used with --server" | 137 | return nil, "--only-server cannot be used with --server" |
| 138 | end | 138 | end |
| 139 | cfg.rocks_servers = { flags["only_server"] } | 139 | cfg.rocks_servers = { args.only_server } |
| 140 | end | 140 | end |
| 141 | 141 | ||
| 142 | return true | 142 | return true |
| @@ -172,7 +172,7 @@ end | |||
| 172 | 172 | ||
| 173 | local init_config | 173 | local init_config |
| 174 | do | 174 | do |
| 175 | local detect_config_via_flags | 175 | local detect_config_via_args |
| 176 | do | 176 | do |
| 177 | local function find_project_dir(project_tree) | 177 | local function find_project_dir(project_tree) |
| 178 | if project_tree then | 178 | if project_tree then |
| @@ -191,7 +191,7 @@ do | |||
| 191 | return nil | 191 | return nil |
| 192 | end | 192 | end |
| 193 | 193 | ||
| 194 | local function find_default_lua_version(flags, project_dir) | 194 | local function find_default_lua_version(args, project_dir) |
| 195 | if hardcoded.FORCE_CONFIG then | 195 | if hardcoded.FORCE_CONFIG then |
| 196 | return nil | 196 | return nil |
| 197 | end | 197 | end |
| @@ -210,7 +210,7 @@ do | |||
| 210 | if mod then | 210 | if mod then |
| 211 | local pok, ver = pcall(mod) | 211 | local pok, ver = pcall(mod) |
| 212 | if pok and type(ver) == "string" and ver:match("%d+.%d+") then | 212 | if pok and type(ver) == "string" and ver:match("%d+.%d+") then |
| 213 | if flags["verbose"] then | 213 | if args.verbose then |
| 214 | util.printout("Defaulting to Lua " .. ver .. " based on " .. f .. " ...") | 214 | util.printout("Defaulting to Lua " .. ver .. " based on " .. f .. " ...") |
| 215 | end | 215 | end |
| 216 | return ver | 216 | return ver |
| @@ -228,13 +228,13 @@ do | |||
| 228 | end) | 228 | end) |
| 229 | end | 229 | end |
| 230 | 230 | ||
| 231 | local function detect_lua_via_flags(flags, project_dir) | 231 | local function detect_lua_via_args(args, project_dir) |
| 232 | local lua_version = flags["lua_version"] | 232 | local lua_version = args.lua_version |
| 233 | or find_default_lua_version(flags, project_dir) | 233 | or find_default_lua_version(args, project_dir) |
| 234 | or (project_dir and find_version_from_config(project_dir)) | 234 | or (project_dir and find_version_from_config(project_dir)) |
| 235 | 235 | ||
| 236 | if flags["lua_dir"] then | 236 | if args.lua_dir then |
| 237 | local detected, err = util.find_lua(flags["lua_dir"], lua_version) | 237 | local detected, err = util.find_lua(args.lua_dir, lua_version) |
| 238 | if not detected then | 238 | if not detected then |
| 239 | die(err) | 239 | die(err) |
| 240 | end | 240 | end |
| @@ -262,14 +262,14 @@ do | |||
| 262 | return {} | 262 | return {} |
| 263 | end | 263 | end |
| 264 | 264 | ||
| 265 | detect_config_via_flags = function(flags) | 265 | detect_config_via_args = function(args) |
| 266 | local project_dir, given = find_project_dir(flags["project_tree"]) | 266 | local project_dir, given = find_project_dir(args.project_tree) |
| 267 | local detected = detect_lua_via_flags(flags, project_dir) | 267 | local detected = detect_lua_via_args(args, project_dir) |
| 268 | if flags["lua_version"] then | 268 | if args.lua_version then |
| 269 | detected.given_lua_version = flags["lua_version"] | 269 | detected.given_lua_version = args.lua_version |
| 270 | end | 270 | end |
| 271 | if flags["lua_dir"] then | 271 | if args.lua_dir then |
| 272 | detected.given_lua_dir = flags["lua_dir"] | 272 | detected.given_lua_dir = args.lua_dir |
| 273 | end | 273 | end |
| 274 | if given then | 274 | if given then |
| 275 | detected.given_project_dir = project_dir | 275 | detected.given_project_dir = project_dir |
| @@ -279,8 +279,8 @@ do | |||
| 279 | end | 279 | end |
| 280 | end | 280 | end |
| 281 | 281 | ||
| 282 | init_config = function(flags) | 282 | init_config = function(args) |
| 283 | local detected = detect_config_via_flags(flags) | 283 | local detected = detect_config_via_args(args) |
| 284 | 284 | ||
| 285 | -- FIXME A quick hack for the experimental Windows build | 285 | -- FIXME A quick hack for the experimental Windows build |
| 286 | if os.getenv("LUAROCKS_CROSS_COMPILING") then | 286 | if os.getenv("LUAROCKS_CROSS_COMPILING") then |
| @@ -513,12 +513,12 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
| 513 | die("Current directory does not exist. Please run LuaRocks from an existing directory.") | 513 | die("Current directory does not exist. Please run LuaRocks from an existing directory.") |
| 514 | end | 514 | end |
| 515 | 515 | ||
| 516 | local ok, err = process_tree_flags(args, cfg.project_dir) | 516 | local ok, err = process_tree_args(args, cfg.project_dir) |
| 517 | if not ok then | 517 | if not ok then |
| 518 | die(err) | 518 | die(err) |
| 519 | end | 519 | end |
| 520 | 520 | ||
| 521 | ok, err = process_server_flags(args) | 521 | ok, err = process_server_args(args) |
| 522 | if not ok then | 522 | if not ok then |
| 523 | die(err) | 523 | die(err) |
| 524 | end | 524 | 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) | |||
| 230 | end | 230 | end |
| 231 | end | 231 | end |
| 232 | 232 | ||
| 233 | local function get_scope(flags) | 233 | local function get_scope(args) |
| 234 | return flags["scope"] | 234 | return args.scope |
| 235 | or (flags["local"] and "user") | 235 | or (args["local"] and "user") |
| 236 | or (flags["project_tree"] and "project") | 236 | or (args.project_tree and "project") |
| 237 | or (cfg.local_by_default and "user") | 237 | or (cfg.local_by_default and "user") |
| 238 | or "system" | 238 | or "system" |
| 239 | end | 239 | end |
| @@ -245,25 +245,25 @@ function config_cmd.command(args) | |||
| 245 | deps.check_lua_libdir(cfg.variables) | 245 | deps.check_lua_libdir(cfg.variables) |
| 246 | 246 | ||
| 247 | -- deprecated flags | 247 | -- deprecated flags |
| 248 | if args["lua_incdir"] then | 248 | if args.lua_incdir then |
| 249 | print(cfg.variables.LUA_INCDIR) | 249 | print(cfg.variables.LUA_INCDIR) |
| 250 | return true | 250 | return true |
| 251 | end | 251 | end |
| 252 | if args["lua_libdir"] then | 252 | if args.lua_libdir then |
| 253 | print(cfg.variables.LUA_LIBDIR) | 253 | print(cfg.variables.LUA_LIBDIR) |
| 254 | return true | 254 | return true |
| 255 | end | 255 | end |
| 256 | if args["lua_ver"] then | 256 | if args.lua_ver then |
| 257 | print(cfg.lua_version) | 257 | print(cfg.lua_version) |
| 258 | return true | 258 | return true |
| 259 | end | 259 | end |
| 260 | if args["system_config"] then | 260 | if args.system_config then |
| 261 | return config_file(cfg.config_files.system) | 261 | return config_file(cfg.config_files.system) |
| 262 | end | 262 | end |
| 263 | if args["user_config"] then | 263 | if args.user_config then |
| 264 | return config_file(cfg.config_files.user) | 264 | return config_file(cfg.config_files.user) |
| 265 | end | 265 | end |
| 266 | if args["rock_trees"] then | 266 | if args.rock_trees then |
| 267 | for _, tree in ipairs(cfg.rocks_trees) do | 267 | for _, tree in ipairs(cfg.rocks_trees) do |
| 268 | if type(tree) == "string" then | 268 | if type(tree) == "string" then |
| 269 | util.printout(dir.normalize(tree)) | 269 | util.printout(dir.normalize(tree)) |
| @@ -298,21 +298,21 @@ function config_cmd.command(args) | |||
| 298 | ["variables.LUA_LIBDIR"] = cfg.variables.LUA_LIBDIR, | 298 | ["variables.LUA_LIBDIR"] = cfg.variables.LUA_LIBDIR, |
| 299 | ["lua_interpreter"] = cfg.lua_interpreter, | 299 | ["lua_interpreter"] = cfg.lua_interpreter, |
| 300 | } | 300 | } |
| 301 | return write_entries(keys, scope, args["unset"]) | 301 | return write_entries(keys, scope, args.unset) |
| 302 | end | 302 | end |
| 303 | 303 | ||
| 304 | if args.key then | 304 | if args.key then |
| 305 | if args.value or args["unset"] then | 305 | if args.value or args.unset then |
| 306 | local scope = get_scope(args) | 306 | local scope = get_scope(args) |
| 307 | return write_entries({ [args.key] = args.value }, scope, args["unset"]) | 307 | return write_entries({ [args.key] = args.value }, scope, args.unset) |
| 308 | else | 308 | else |
| 309 | return print_entry(args.key, cfg, args["json"]) | 309 | return print_entry(args.key, cfg, args.json) |
| 310 | end | 310 | end |
| 311 | end | 311 | end |
| 312 | 312 | ||
| 313 | local cleancfg = cleanup(cfg) | 313 | local cleancfg = cleanup(cfg) |
| 314 | 314 | ||
| 315 | if args["json"] then | 315 | if args.json then |
| 316 | return print_json(cleancfg) | 316 | return print_json(cleancfg) |
| 317 | else | 317 | else |
| 318 | print(persist.save_from_table_to_string(cleancfg)) | 318 | 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) | |||
| 63 | local name = util.adjust_name_and_namespace(args.rock, args) | 63 | local name = util.adjust_name_and_namespace(args.rock, args) |
| 64 | local version = args.version | 64 | local version = args.version |
| 65 | local query = queries.new(name, version) | 65 | local query = queries.new(name, version) |
| 66 | local iname, iversion, repo = search.pick_installed_rock(query, args["tree"]) | 66 | local iname, iversion, repo = search.pick_installed_rock(query, args.tree) |
| 67 | if not iname then | 67 | if not iname then |
| 68 | util.printout(name..(version and " "..version or "").." is not installed. Looking for it in the rocks servers...") | 68 | util.printout(name..(version and " "..version or "").." is not installed. Looking for it in the rocks servers...") |
| 69 | return try_to_open_homepage(name, version) | 69 | return try_to_open_homepage(name, version) |
| @@ -74,7 +74,7 @@ function doc.command(args) | |||
| 74 | if not rockspec then return nil,err end | 74 | if not rockspec then return nil,err end |
| 75 | local descript = rockspec.description or {} | 75 | local descript = rockspec.description or {} |
| 76 | 76 | ||
| 77 | if args["home"] then | 77 | if args.home then |
| 78 | return show_homepage(descript.homepage, name, version) | 78 | return show_homepage(descript.homepage, name, version) |
| 79 | end | 79 | end |
| 80 | 80 | ||
| @@ -90,7 +90,7 @@ function doc.command(args) | |||
| 90 | end | 90 | end |
| 91 | end | 91 | end |
| 92 | if not docdir then | 92 | if not docdir then |
| 93 | if descript.homepage and not args["list"] then | 93 | if descript.homepage and not args.list then |
| 94 | util.printout("Local documentation directory not found -- opening "..descript.homepage.." ...") | 94 | util.printout("Local documentation directory not found -- opening "..descript.homepage.." ...") |
| 95 | fs.browser(descript.homepage) | 95 | fs.browser(descript.homepage) |
| 96 | return true | 96 | return true |
| @@ -104,7 +104,7 @@ function doc.command(args) | |||
| 104 | local extensions = { htmlpatt, "%.md$", "%.txt$", "%.textile$", "" } | 104 | local extensions = { htmlpatt, "%.md$", "%.txt$", "%.textile$", "" } |
| 105 | local basenames = { "index", "readme", "manual" } | 105 | local basenames = { "index", "readme", "manual" } |
| 106 | 106 | ||
| 107 | local porcelain = args["porcelain"] | 107 | local porcelain = args.porcelain |
| 108 | if #files > 0 then | 108 | if #files > 0 then |
| 109 | util.title("Documentation files for "..name.." "..version, porcelain) | 109 | util.title("Documentation files for "..name.." "..version, porcelain) |
| 110 | if porcelain then | 110 | if porcelain then |
| @@ -119,7 +119,7 @@ function doc.command(args) | |||
| 119 | end | 119 | end |
| 120 | end | 120 | end |
| 121 | 121 | ||
| 122 | if args["list"] then | 122 | if args.list then |
| 123 | return true | 123 | return true |
| 124 | end | 124 | end |
| 125 | 125 | ||
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 | |||
| 27 | -- @return boolean or (nil, string): true if successful or nil followed | 27 | -- @return boolean or (nil, string): true if successful or nil followed |
| 28 | -- by an error message. | 28 | -- by an error message. |
| 29 | function cmd_download.command(args) | 29 | function cmd_download.command(args) |
| 30 | if not args.name and not args["all"] then | 30 | if not args.name and not args.all then |
| 31 | return nil, "Argument missing. "..util.see_help("download") | 31 | return nil, "Argument missing. "..util.see_help("download") |
| 32 | end | 32 | end |
| 33 | 33 | ||
| @@ -37,15 +37,15 @@ function cmd_download.command(args) | |||
| 37 | 37 | ||
| 38 | local arch | 38 | local arch |
| 39 | 39 | ||
| 40 | if args["source"] then | 40 | if args.source then |
| 41 | arch = "src" | 41 | arch = "src" |
| 42 | elseif args["rockspec"] then | 42 | elseif args.rockspec then |
| 43 | arch = "rockspec" | 43 | arch = "rockspec" |
| 44 | elseif args["arch"] then | 44 | elseif args.arch then |
| 45 | arch = args["arch"] | 45 | arch = args.arch |
| 46 | end | 46 | end |
| 47 | 47 | ||
| 48 | local dl, err = download.download(arch, name:lower(), version, args["all"]) | 48 | local dl, err = download.download(arch, name:lower(), version, args.all) |
| 49 | return dl and true, err | 49 | return dl and true, err |
| 50 | end | 50 | end |
| 51 | 51 | ||
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) | |||
| 223 | elseif args.rock:match("%.rock$") then | 223 | elseif args.rock:match("%.rock$") then |
| 224 | local deps_mode = deps.get_deps_mode(args) | 224 | local deps_mode = deps.get_deps_mode(args) |
| 225 | local opts = install.opts({ | 225 | local opts = install.opts({ |
| 226 | namespace = args["namespace"], | 226 | namespace = args.namespace, |
| 227 | keep = not not args["keep"], | 227 | keep = not not args.keep, |
| 228 | force = not not args["force"], | 228 | force = not not args.force, |
| 229 | force_fast = not not args["force_fast"], | 229 | force_fast = not not args.force_fast, |
| 230 | no_doc = not not args["no_doc"], | 230 | no_doc = not not args.no_doc, |
| 231 | deps_mode = deps_mode, | 231 | deps_mode = deps_mode, |
| 232 | verify = not not args["verify"], | 232 | verify = not not args.verify, |
| 233 | }) | 233 | }) |
| 234 | if args["only_deps"] then | 234 | if args.only_deps then |
| 235 | return install_rock_file_deps(args.rock, opts) | 235 | return install_rock_file_deps(args.rock, opts) |
| 236 | else | 236 | else |
| 237 | return install_rock_file(args.rock, opts) | 237 | 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) | |||
| 73 | local query = queries.new(args.filter and args.filter:lower() or "", args.version, true) | 73 | local query = queries.new(args.filter and args.filter:lower() or "", args.version, true) |
| 74 | local trees = cfg.rocks_trees | 74 | local trees = cfg.rocks_trees |
| 75 | local title = "Rocks installed for Lua "..cfg.lua_version | 75 | local title = "Rocks installed for Lua "..cfg.lua_version |
| 76 | if args["tree"] then | 76 | if args.tree then |
| 77 | trees = { args["tree"] } | 77 | trees = { args.tree } |
| 78 | title = title .. " in " .. args["tree"] | 78 | title = title .. " in " .. args.tree |
| 79 | end | 79 | end |
| 80 | 80 | ||
| 81 | if args["outdated"] then | 81 | if args.outdated then |
| 82 | return list_outdated(trees, query, args["porcelain"]) | 82 | return list_outdated(trees, query, args.porcelain) |
| 83 | end | 83 | end |
| 84 | 84 | ||
| 85 | local results = {} | 85 | local results = {} |
| @@ -89,8 +89,8 @@ function list.command(args) | |||
| 89 | util.warning(err) | 89 | util.warning(err) |
| 90 | end | 90 | end |
| 91 | end | 91 | end |
| 92 | util.title(title, args["porcelain"]) | 92 | util.title(title, args.porcelain) |
| 93 | search.print_result_tree(results, args["porcelain"]) | 93 | search.print_result_tree(results, args.porcelain) |
| 94 | return true | 94 | return true |
| 95 | end | 95 | end |
| 96 | 96 | ||
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) | |||
| 87 | minimal_mode = true, | 87 | minimal_mode = true, |
| 88 | deps_mode = deps.get_deps_mode(args), | 88 | deps_mode = deps.get_deps_mode(args), |
| 89 | build_only_deps = false, | 89 | build_only_deps = false, |
| 90 | namespace = args["namespace"], | 90 | namespace = args.namespace, |
| 91 | branch = not not args["branch"], | 91 | branch = not not args.branch, |
| 92 | verify = not not args["verify"], | 92 | verify = not not args.verify, |
| 93 | }) | 93 | }) |
| 94 | 94 | ||
| 95 | if args["sign"] and not args["pack_binary_rock"] then | 95 | if args.sign and not args.pack_binary_rock then |
| 96 | return nil, "In the make command, --sign is meant to be used only with --pack-binary-rock" | 96 | return nil, "In the make command, --sign is meant to be used only with --pack-binary-rock" |
| 97 | end | 97 | end |
| 98 | 98 | ||
| 99 | if args["pack_binary_rock"] then | 99 | if args.pack_binary_rock then |
| 100 | return pack.pack_binary_rock(name, rockspec.version, args["sign"], function() | 100 | return pack.pack_binary_rock(name, rockspec.version, args.sign, function() |
| 101 | return build.build_rockspec(rockspec, opts) | 101 | return build.build_rockspec(rockspec, opts) |
| 102 | end) | 102 | end) |
| 103 | else | 103 | else |
| @@ -107,8 +107,8 @@ function make.command(args) | |||
| 107 | if not ok then return nil, err end | 107 | if not ok then return nil, err end |
| 108 | local name, version = ok, err | 108 | local name, version = ok, err |
| 109 | 109 | ||
| 110 | if (not args["keep"]) and not cfg.keep_other_versions then | 110 | if (not args.keep) and not cfg.keep_other_versions then |
| 111 | local ok, err = remove.remove_other_versions(name, version, args["force"], args["force_fast"]) | 111 | local ok, err = remove.remove_other_versions(name, version, args.force, args.force_fast) |
| 112 | if not ok then util.printerr(err) end | 112 | if not ok then util.printerr(err) end |
| 113 | end | 113 | end |
| 114 | 114 | ||
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) | |||
| 30 | else | 30 | else |
| 31 | local name = util.adjust_name_and_namespace(args.rock, args) | 31 | local name = util.adjust_name_and_namespace(args.rock, args) |
| 32 | local query = queries.new(name, args.version) | 32 | local query = queries.new(name, args.version) |
| 33 | file, err = pack.pack_installed_rock(query, args["tree"]) | 33 | file, err = pack.pack_installed_rock(query, args.tree) |
| 34 | end | 34 | end |
| 35 | return pack.report_and_sign_local_file(file, err, args["sign"]) | 35 | return pack.report_and_sign_local_file(file, err, args.sign) |
| 36 | end | 36 | end |
| 37 | 37 | ||
| 38 | return cmd_pack | 38 | 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 | |||
| 32 | --- Driver function for "path" command. | 32 | --- Driver function for "path" command. |
| 33 | -- @return boolean This function always succeeds. | 33 | -- @return boolean This function always succeeds. |
| 34 | function path_cmd.command(args) | 34 | function path_cmd.command(args) |
| 35 | local lr_path, lr_cpath, lr_bin = cfg.package_paths(args["tree"]) | 35 | local lr_path, lr_cpath, lr_bin = cfg.package_paths(args.tree) |
| 36 | local path_sep = cfg.export_path_separator | 36 | local path_sep = cfg.export_path_separator |
| 37 | 37 | ||
| 38 | if args["lr_path"] then | 38 | if args.lr_path then |
| 39 | util.printout(util.cleanup_path(lr_path, ';', cfg.lua_version)) | 39 | util.printout(util.cleanup_path(lr_path, ';', cfg.lua_version)) |
| 40 | return true | 40 | return true |
| 41 | elseif args["lr_cpath"] then | 41 | elseif args.lr_cpath then |
| 42 | util.printout(util.cleanup_path(lr_cpath, ';', cfg.lua_version)) | 42 | util.printout(util.cleanup_path(lr_cpath, ';', cfg.lua_version)) |
| 43 | return true | 43 | return true |
| 44 | elseif args["lr_bin"] then | 44 | elseif args.lr_bin then |
| 45 | util.printout(util.cleanup_path(lr_bin, path_sep)) | 45 | util.printout(util.cleanup_path(lr_bin, path_sep)) |
| 46 | return true | 46 | return true |
| 47 | end | 47 | end |
| 48 | 48 | ||
| 49 | if args["append"] then | 49 | if args.append then |
| 50 | lr_path = package.path .. ";" .. lr_path | 50 | lr_path = package.path .. ";" .. lr_path |
| 51 | lr_cpath = package.cpath .. ";" .. lr_cpath | 51 | lr_cpath = package.cpath .. ";" .. lr_cpath |
| 52 | lr_bin = os.getenv("PATH") .. path_sep .. lr_bin | 52 | lr_bin = os.getenv("PATH") .. path_sep .. lr_bin |
| @@ -60,7 +60,7 @@ function path_cmd.command(args) | |||
| 60 | 60 | ||
| 61 | util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version))) | 61 | util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version))) |
| 62 | util.printout(fs.export_cmd(lcpath_var, util.cleanup_path(lr_cpath, ';', cfg.lua_version))) | 62 | util.printout(fs.export_cmd(lcpath_var, util.cleanup_path(lr_cpath, ';', cfg.lua_version))) |
| 63 | if not args["no_bin"] then | 63 | if not args.no_bin then |
| 64 | util.printout(fs.export_cmd("PATH", util.cleanup_path(lr_bin, path_sep))) | 64 | util.printout(fs.export_cmd("PATH", util.cleanup_path(lr_bin, path_sep))) |
| 65 | end | 65 | end |
| 66 | return true | 66 | 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.]] | |||
| 32 | end | 32 | end |
| 33 | 33 | ||
| 34 | function purge.command(args) | 34 | function purge.command(args) |
| 35 | local tree = args["tree"] | 35 | local tree = args.tree |
| 36 | 36 | ||
| 37 | if type(tree) ~= "string" then | 37 | if type(tree) ~= "string" then |
| 38 | return nil, "The --tree argument is mandatory. "..util.see_help("purge") | 38 | return nil, "The --tree argument is mandatory. "..util.see_help("purge") |
| @@ -49,15 +49,15 @@ function purge.command(args) | |||
| 49 | search.local_manifest_search(results, path.rocks_dir(tree), queries.all()) | 49 | search.local_manifest_search(results, path.rocks_dir(tree), queries.all()) |
| 50 | 50 | ||
| 51 | local sort = function(a,b) return vers.compare_versions(b,a) end | 51 | local sort = function(a,b) return vers.compare_versions(b,a) end |
| 52 | if args["old_versions"] then | 52 | if args.old_versions then |
| 53 | sort = vers.compare_versions | 53 | sort = vers.compare_versions |
| 54 | end | 54 | end |
| 55 | 55 | ||
| 56 | for package, versions in util.sortedpairs(results) do | 56 | for package, versions in util.sortedpairs(results) do |
| 57 | for version, _ in util.sortedpairs(versions, sort) do | 57 | for version, _ in util.sortedpairs(versions, sort) do |
| 58 | if args["old_versions"] then | 58 | if args.old_versions then |
| 59 | util.printout("Keeping "..package.." "..version.."...") | 59 | util.printout("Keeping "..package.." "..version.."...") |
| 60 | local ok, err = remove.remove_other_versions(package, version, args["force"], args["force_fast"]) | 60 | local ok, err = remove.remove_other_versions(package, version, args.force, args.force_fast) |
| 61 | if not ok then | 61 | if not ok then |
| 62 | util.printerr(err) | 62 | util.printerr(err) |
| 63 | end | 63 | 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 | |||
| 40 | function cmd_remove.command(args) | 40 | function cmd_remove.command(args) |
| 41 | local name = util.adjust_name_and_namespace(args.rock, args) | 41 | local name = util.adjust_name_and_namespace(args.rock, args) |
| 42 | 42 | ||
| 43 | local deps_mode = args["deps_mode"] or cfg.deps_mode | 43 | local deps_mode = args.deps_mode or cfg.deps_mode |
| 44 | 44 | ||
| 45 | local ok, err = fs.check_command_permissions(args) | 45 | local ok, err = fs.check_command_permissions(args) |
| 46 | if not ok then return nil, err, cmd.errorcodes.PERMISSIONDENIED end | 46 | if not ok then return nil, err, cmd.errorcodes.PERMISSIONDENIED end |
| @@ -60,7 +60,7 @@ function cmd_remove.command(args) | |||
| 60 | return nil, "Could not find rock '"..name..(version and " "..version or "").."' in "..path.rocks_tree_to_string(cfg.root_dir) | 60 | return nil, "Could not find rock '"..name..(version and " "..version or "").."' in "..path.rocks_tree_to_string(cfg.root_dir) |
| 61 | end | 61 | end |
| 62 | 62 | ||
| 63 | local ok, err = remove.remove_search_results(results, name, deps_mode, args["force"], args["force_fast"]) | 63 | local ok, err = remove.remove_search_results(results, name, deps_mode, args.force, args.force_fast) |
| 64 | if not ok then | 64 | if not ok then |
| 65 | return nil, err | 65 | return nil, err |
| 66 | end | 66 | 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) | |||
| 57 | 57 | ||
| 58 | local name = util.adjust_name_and_namespace(args.name, args) | 58 | local name = util.adjust_name_and_namespace(args.name, args) |
| 59 | 59 | ||
| 60 | if args["all"] then | 60 | if args.all then |
| 61 | name, args.version = "", nil | 61 | name, args.version = "", nil |
| 62 | end | 62 | end |
| 63 | 63 | ||
| 64 | if not args.name and not args["all"] then | 64 | if not args.name and not args.all then |
| 65 | return nil, "Enter name and version or use --all. "..util.see_help("search") | 65 | return nil, "Enter name and version or use --all. "..util.see_help("search") |
| 66 | end | 66 | end |
| 67 | 67 | ||
| 68 | local query = queries.new(name:lower(), args.version, true) | 68 | local query = queries.new(name:lower(), args.version, true) |
| 69 | local result_tree, err = search.search_repos(query) | 69 | local result_tree, err = search.search_repos(query) |
| 70 | local porcelain = args["porcelain"] | 70 | local porcelain = args.porcelain |
| 71 | local full_name = name .. (args.version and " " .. args.version or "") | 71 | local full_name = name .. (args.version and " " .. args.version or "") |
| 72 | util.title(full_name .. " - Search results for Lua "..cfg.lua_version..":", porcelain, "=") | 72 | util.title(full_name .. " - Search results for Lua "..cfg.lua_version..":", porcelain, "=") |
| 73 | local sources, binaries = split_source_and_binary_results(result_tree) | 73 | local sources, binaries = split_source_and_binary_results(result_tree) |
| 74 | if next(sources) and not args["binary"] then | 74 | if next(sources) and not args.binary then |
| 75 | util.title("Rockspecs and source rocks:", porcelain) | 75 | util.title("Rockspecs and source rocks:", porcelain) |
| 76 | search.print_result_tree(sources, porcelain) | 76 | search.print_result_tree(sources, porcelain) |
| 77 | end | 77 | end |
| 78 | if next(binaries) and not args["source"] then | 78 | if next(binaries) and not args.source then |
| 79 | util.title("Binary and pure-Lua rocks:", porcelain) | 79 | util.title("Binary and pure-Lua rocks:", porcelain) |
| 80 | search.print_result_tree(binaries, porcelain) | 80 | search.print_result_tree(binaries, porcelain) |
| 81 | end | 81 | 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) | |||
| 266 | local query = queries.new(name, version) | 266 | local query = queries.new(name, version) |
| 267 | 267 | ||
| 268 | local repo, repo_url | 268 | local repo, repo_url |
| 269 | name, version, repo, repo_url = search.pick_installed_rock(query, args["tree"]) | 269 | name, version, repo, repo_url = search.pick_installed_rock(query, args.tree) |
| 270 | if not name then | 270 | if not name then |
| 271 | return nil, version | 271 | return nil, version |
| 272 | end | 272 | end |
| @@ -282,32 +282,32 @@ function show.command(args) | |||
| 282 | if not manifest then return nil,err end | 282 | if not manifest then return nil,err end |
| 283 | local minfo = manifest.repository[name][version][1] | 283 | local minfo = manifest.repository[name][version][1] |
| 284 | 284 | ||
| 285 | if args["rock_tree"] then util.printout(tree) | 285 | if args.rock_tree then util.printout(tree) |
| 286 | elseif args["rock_namespace"] then util.printout(namespace) | 286 | elseif args.rock_namespace then util.printout(namespace) |
| 287 | elseif args["rock_dir"] then util.printout(directory) | 287 | elseif args.rock_dir then util.printout(directory) |
| 288 | elseif args["home"] then util.printout(descript.homepage) | 288 | elseif args.home then util.printout(descript.homepage) |
| 289 | elseif args["rock_license"] then util.printout(descript.license) | 289 | elseif args.rock_license then util.printout(descript.license) |
| 290 | elseif args["issues"] then util.printout(descript.issues_url) | 290 | elseif args.issues then util.printout(descript.issues_url) |
| 291 | elseif args["labels"] then util.printout(descript.labels and table.concat(descript.labels, "\n")) | 291 | elseif args.labels then util.printout(descript.labels and table.concat(descript.labels, "\n")) |
| 292 | elseif args["modules"] then util.printout(keys_as_string(minfo.modules, "\n")) | 292 | elseif args.modules then util.printout(keys_as_string(minfo.modules, "\n")) |
| 293 | elseif args["deps"] then | 293 | elseif args.deps then |
| 294 | for _, dep in ipairs(rockspec.dependencies) do | 294 | for _, dep in ipairs(rockspec.dependencies) do |
| 295 | util.printout(tostring(dep)) | 295 | util.printout(tostring(dep)) |
| 296 | end | 296 | end |
| 297 | elseif args["build_deps"] then | 297 | elseif args.build_deps then |
| 298 | for _, dep in ipairs(rockspec.build_dependencies) do | 298 | for _, dep in ipairs(rockspec.build_dependencies) do |
| 299 | util.printout(tostring(dep)) | 299 | util.printout(tostring(dep)) |
| 300 | end | 300 | end |
| 301 | elseif args["test_deps"] then | 301 | elseif args.test_deps then |
| 302 | for _, dep in ipairs(rockspec.test_dependencies) do | 302 | for _, dep in ipairs(rockspec.test_dependencies) do |
| 303 | util.printout(tostring(dep)) | 303 | util.printout(tostring(dep)) |
| 304 | end | 304 | end |
| 305 | elseif args["rockspec"] then util.printout(rockspec_file) | 305 | elseif args.rockspec then util.printout(rockspec_file) |
| 306 | elseif args["mversion"] then util.printout(version) | 306 | elseif args.mversion then util.printout(version) |
| 307 | elseif args["porcelain"] then | 307 | elseif args.porcelain then |
| 308 | show_rock(porcelain_template, namespace, name, version, rockspec, repo, minfo, args["tree"]) | 308 | show_rock(porcelain_template, namespace, name, version, rockspec, repo, minfo, args.tree) |
| 309 | else | 309 | else |
| 310 | show_rock(friendly_template, namespace, name, version, rockspec, repo, minfo, args["tree"]) | 310 | show_rock(friendly_template, namespace, name, version, rockspec, repo, minfo, args.tree) |
| 311 | end | 311 | end |
| 312 | return true | 312 | return true |
| 313 | end | 313 | 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 | |||
| 33 | 33 | ||
| 34 | function cmd_test.command(args) | 34 | function cmd_test.command(args) |
| 35 | if args.rockspec and args.rockspec:match("rockspec$") then | 35 | if args.rockspec and args.rockspec:match("rockspec$") then |
| 36 | return test.run_test_suite(args.rockspec, args["test_type"], args.args) | 36 | return test.run_test_suite(args.rockspec, args.test_type, args.args) |
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | table.insert(args.args, 1, args.rockspec) | 39 | table.insert(args.args, 1, args.rockspec) |
| @@ -43,7 +43,7 @@ function cmd_test.command(args) | |||
| 43 | return nil, err | 43 | return nil, err |
| 44 | end | 44 | end |
| 45 | 45 | ||
| 46 | return test.run_test_suite(rockspec, args["test_type"], args.args) | 46 | return test.run_test_suite(rockspec, args.test_type, args.args) |
| 47 | end | 47 | end |
| 48 | 48 | ||
| 49 | return cmd_test | 49 | 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) | |||
| 162 | end | 162 | end |
| 163 | end | 163 | end |
| 164 | 164 | ||
| 165 | return run_unpacker(url, args["force"]) | 165 | return run_unpacker(url, args.force) |
| 166 | end | 166 | end |
| 167 | 167 | ||
| 168 | return unpack | 168 | 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) | |||
| 58 | if not res.module then | 58 | if not res.module then |
| 59 | util.printout("Will create new module (" .. tostring(rockspec.package) .. ")") | 59 | util.printout("Will create new module (" .. tostring(rockspec.package) .. ")") |
| 60 | end | 60 | end |
| 61 | if res.version and not args["force"] then | 61 | if res.version and not args.force then |
| 62 | return nil, "Revision "..rockspec.version.." already exists on the server. "..util.see_help("upload") | 62 | return nil, "Revision "..rockspec.version.." already exists on the server. "..util.see_help("upload") |
| 63 | end | 63 | end |
| 64 | 64 | ||
| 65 | local sigfname | 65 | local sigfname |
| 66 | local rock_sigfname | 66 | local rock_sigfname |
| 67 | 67 | ||
| 68 | if args["sign"] then | 68 | if args.sign then |
| 69 | sigfname, err = signing.sign_file(args.rockspec) | 69 | sigfname, err = signing.sign_file(args.rockspec) |
| 70 | if err then | 70 | if err then |
| 71 | return nil, "Failed signing rockspec: " .. err | 71 | return nil, "Failed signing rockspec: " .. err |
| @@ -74,13 +74,13 @@ function upload.command(args) | |||
| 74 | end | 74 | end |
| 75 | 75 | ||
| 76 | local rock_fname | 76 | local rock_fname |
| 77 | if not args["skip_pack"] and not is_dev_version(rockspec.version) then | 77 | if not args.skip_pack and not is_dev_version(rockspec.version) then |
| 78 | util.printout("Packing " .. tostring(rockspec.package)) | 78 | util.printout("Packing " .. tostring(rockspec.package)) |
| 79 | rock_fname, err = pack.pack_source_rock(args.rockspec) | 79 | rock_fname, err = pack.pack_source_rock(args.rockspec) |
| 80 | if not rock_fname then | 80 | if not rock_fname then |
| 81 | return nil, err | 81 | return nil, err |
| 82 | end | 82 | end |
| 83 | if args["sign"] then | 83 | if args.sign then |
| 84 | rock_sigfname, err = signing.sign_file(rock_fname) | 84 | rock_sigfname, err = signing.sign_file(rock_fname) |
| 85 | if err then | 85 | if err then |
| 86 | return nil, "Failed signing rock: " .. err | 86 | 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) | |||
| 278 | version = nil | 278 | version = nil |
| 279 | end | 279 | end |
| 280 | 280 | ||
| 281 | if args["tag"] then | 281 | if args.tag then |
| 282 | if not version then | 282 | if not version then |
| 283 | version = args["tag"]:gsub("^v", "") | 283 | version = args.tag:gsub("^v", "") |
| 284 | end | 284 | end |
| 285 | end | 285 | end |
| 286 | 286 | ||
| @@ -305,27 +305,27 @@ function write_rockspec.command(args) | |||
| 305 | end | 305 | end |
| 306 | version = version or "dev" | 306 | version = version or "dev" |
| 307 | 307 | ||
| 308 | local filename = args["output"] or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") | 308 | local filename = args.output or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") |
| 309 | 309 | ||
| 310 | local url = detect_url(location) | 310 | local url = detect_url(location) |
| 311 | local homepage = detect_homepage(url, args["homepage"]) | 311 | local homepage = detect_homepage(url, args.homepage) |
| 312 | 312 | ||
| 313 | local rockspec, err = rockspecs.from_persisted_table(filename, { | 313 | local rockspec, err = rockspecs.from_persisted_table(filename, { |
| 314 | rockspec_format = args["rockspec_format"], | 314 | rockspec_format = args.rockspec_format, |
| 315 | package = name, | 315 | package = name, |
| 316 | version = version.."-1", | 316 | version = version.."-1", |
| 317 | source = { | 317 | source = { |
| 318 | url = url, | 318 | url = url, |
| 319 | tag = args["tag"], | 319 | tag = args.tag, |
| 320 | }, | 320 | }, |
| 321 | description = { | 321 | description = { |
| 322 | summary = args["summary"] or "*** please specify description summary ***", | 322 | summary = args.summary or "*** please specify description summary ***", |
| 323 | detailed = args["detailed"] or "*** please enter a detailed description ***", | 323 | detailed = args.detailed or "*** please enter a detailed description ***", |
| 324 | homepage = homepage, | 324 | homepage = homepage, |
| 325 | license = args["license"] or "*** please specify a license ***", | 325 | license = args.license or "*** please specify a license ***", |
| 326 | }, | 326 | }, |
| 327 | dependencies = { | 327 | dependencies = { |
| 328 | lua_version_dep[args["lua_versions"]], | 328 | lua_version_dep[args.lua_versions], |
| 329 | }, | 329 | }, |
| 330 | build = {}, | 330 | build = {}, |
| 331 | }) | 331 | }) |
| @@ -342,7 +342,7 @@ function write_rockspec.command(args) | |||
| 342 | rockspec.source.file = dir.base_name(location) | 342 | rockspec.source.file = dir.base_name(location) |
| 343 | if not dir.is_basic_protocol(rockspec.source.protocol) then | 343 | if not dir.is_basic_protocol(rockspec.source.protocol) then |
| 344 | if version ~= "dev" then | 344 | if version ~= "dev" then |
| 345 | rockspec.source.tag = args["tag"] or "v" .. version | 345 | rockspec.source.tag = args.tag or "v" .. version |
| 346 | end | 346 | end |
| 347 | end | 347 | end |
| 348 | rockspec.source.dir = nil | 348 | rockspec.source.dir = nil |
| @@ -364,10 +364,10 @@ function write_rockspec.command(args) | |||
| 364 | end | 364 | end |
| 365 | 365 | ||
| 366 | local libs = nil | 366 | local libs = nil |
| 367 | if args["lib"] then | 367 | if args.lib then |
| 368 | libs = {} | 368 | libs = {} |
| 369 | rockspec.external_dependencies = {} | 369 | rockspec.external_dependencies = {} |
| 370 | for lib in args["lib"]:gmatch("([^,]+)") do | 370 | for lib in args.lib:gmatch("([^,]+)") do |
| 371 | table.insert(libs, lib) | 371 | table.insert(libs, lib) |
| 372 | rockspec.external_dependencies[lib:upper()] = { | 372 | rockspec.external_dependencies[lib:upper()] = { |
| 373 | library = lib | 373 | library = lib |
| @@ -378,13 +378,13 @@ function write_rockspec.command(args) | |||
| 378 | local ok, err = fs.change_dir(local_dir) | 378 | local ok, err = fs.change_dir(local_dir) |
| 379 | if not ok then return nil, "Failed reaching files from project - error entering directory "..local_dir end | 379 | if not ok then return nil, "Failed reaching files from project - error entering directory "..local_dir end |
| 380 | 380 | ||
| 381 | if not (args["summary"] and args["detailed"]) then | 381 | if not (args.summary and args.detailed) then |
| 382 | local summary, detailed = detect_description() | 382 | local summary, detailed = detect_description() |
| 383 | rockspec.description.summary = args["summary"] or summary | 383 | rockspec.description.summary = args.summary or summary |
| 384 | rockspec.description.detailed = args["detailed"] or detailed | 384 | rockspec.description.detailed = args.detailed or detailed |
| 385 | end | 385 | end |
| 386 | 386 | ||
| 387 | if not args["license"] then | 387 | if not args.license then |
| 388 | local license, fulltext = check_license() | 388 | local license, fulltext = check_license() |
| 389 | if license then | 389 | if license then |
| 390 | rockspec.description.license = license | 390 | 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) | |||
| 570 | return nil, "Failed finding Lua library. You may need to configure LUA_LIBDIR.", "dependency" | 570 | return nil, "Failed finding Lua library. You may need to configure LUA_LIBDIR.", "dependency" |
| 571 | end | 571 | end |
| 572 | 572 | ||
| 573 | function deps.get_deps_mode(flags) | 573 | function deps.get_deps_mode(args) |
| 574 | if flags["deps_mode"] then | 574 | if args.deps_mode then |
| 575 | return flags["deps_mode"] | 575 | return args.deps_mode |
| 576 | else | 576 | else |
| 577 | return cfg.deps_mode | 577 | return cfg.deps_mode |
| 578 | end | 578 | 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 | |||
| 1092 | 1092 | ||
| 1093 | --- Check if user has write permissions for the command. | 1093 | --- Check if user has write permissions for the command. |
| 1094 | -- Assumes the configuration variables under cfg have been previously set up. | 1094 | -- Assumes the configuration variables under cfg have been previously set up. |
| 1095 | -- @param flags table: the flags table passed to run() drivers. | 1095 | -- @param args table: the args table passed to run() drivers. |
| 1096 | -- @return boolean or (boolean, string): true on success, false on failure, | 1096 | -- @return boolean or (boolean, string): true on success, false on failure, |
| 1097 | -- plus an error message. | 1097 | -- plus an error message. |
| 1098 | function fs_lua.check_command_permissions(flags) | 1098 | function fs_lua.check_command_permissions(args) |
| 1099 | local ok = true | 1099 | local ok = true |
| 1100 | local err = "" | 1100 | local err = "" |
| 1101 | for _, directory in ipairs { cfg.rocks_dir, cfg.deploy_lua_dir, cfg.deploy_bin_dir, cfg.deploy_lua_dir } do | 1101 | 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) | |||
| 1124 | if ok then | 1124 | if ok then |
| 1125 | return true | 1125 | return true |
| 1126 | else | 1126 | else |
| 1127 | if flags["local"] or cfg.local_by_default then | 1127 | if args["local"] or cfg.local_by_default then |
| 1128 | err = err .. " \n-- please check your permissions." | 1128 | err = err .. " \n-- please check your permissions." |
| 1129 | else | 1129 | else |
| 1130 | err = err .. " \n-- you may want to run as a privileged user or use your local tree with --local." | 1130 | 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 | |||
| 245 | 245 | ||
| 246 | end | 246 | end |
| 247 | 247 | ||
| 248 | function api.new(flags) | 248 | function api.new(args) |
| 249 | local self = {} | 249 | local self = {} |
| 250 | setmetatable(self, { __index = Api }) | 250 | setmetatable(self, { __index = Api }) |
| 251 | self.config = self:load_config() or {} | 251 | self.config = self:load_config() or {} |
| 252 | self.config.server = flags["server"] or self.config.server or cfg.upload.server | 252 | self.config.server = args.server or self.config.server or cfg.upload.server |
| 253 | self.config.version = self.config.version or cfg.upload.version | 253 | self.config.version = self.config.version or cfg.upload.version |
| 254 | self.config.key = flags["temp_key"] or flags["api_key"] or self.config.key | 254 | self.config.key = args.temp_key or args.api_key or self.config.key |
| 255 | self.debug = flags["debug"] | 255 | self.debug = args.debug |
| 256 | if not self.config.key then | 256 | if not self.config.key then |
| 257 | return nil, "You need an API key to upload rocks.\n" .. | 257 | return nil, "You need an API key to upload rocks.\n" .. |
| 258 | "Navigate to "..self.config.server.."/settings to get a key\n" .. | 258 | "Navigate to "..self.config.server.."/settings to get a key\n" .. |
| 259 | "and then pass it through the --api-key=<key> flag." | 259 | "and then pass it through the --api-key=<key> flag." |
| 260 | end | 260 | end |
| 261 | if flags["api_key"] then | 261 | if args.api_key then |
| 262 | self:save_config() | 262 | self:save_config() |
| 263 | end | 263 | end |
| 264 | return self | 264 | 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) | |||
| 338 | return ("%q"):format(s) | 338 | return ("%q"):format(s) |
| 339 | end | 339 | end |
| 340 | 340 | ||
| 341 | --- Normalize the --namespace flag and the user/rock syntax for namespaces. | 341 | --- Normalize the --namespace option and the user/rock syntax for namespaces. |
| 342 | -- If a namespace is given in user/rock syntax, update the --namespace flag; | 342 | -- If a namespace is given in user/rock syntax, update the --namespace option; |
| 343 | -- If a namespace is given in --namespace flag, update the user/rock syntax. | 343 | -- If a namespace is given in --namespace option, update the user/rock syntax. |
| 344 | -- In case of conflicts, the user/rock syntax takes precedence. | 344 | -- In case of conflicts, the user/rock syntax takes precedence. |
| 345 | function util.adjust_name_and_namespace(ns_name, flags) | 345 | function util.adjust_name_and_namespace(ns_name, args) |
| 346 | assert(type(ns_name) == "string" or not ns_name) | 346 | assert(type(ns_name) == "string" or not ns_name) |
| 347 | assert(type(flags) == "table") | 347 | assert(type(args) == "table") |
| 348 | 348 | ||
| 349 | if not ns_name then | 349 | if not ns_name then |
| 350 | return | 350 | return |
| @@ -354,10 +354,10 @@ function util.adjust_name_and_namespace(ns_name, flags) | |||
| 354 | 354 | ||
| 355 | local name, namespace = util.split_namespace(ns_name) | 355 | local name, namespace = util.split_namespace(ns_name) |
| 356 | if namespace then | 356 | if namespace then |
| 357 | flags["namespace"] = namespace | 357 | args.namespace = namespace |
| 358 | end | 358 | end |
| 359 | if flags["namespace"] then | 359 | if args.namespace then |
| 360 | name = flags["namespace"] .. "/" .. name | 360 | name = args.namespace .. "/" .. name |
| 361 | end | 361 | end |
| 362 | return name:lower() | 362 | return name:lower() |
| 363 | end | 363 | end |
