From bb0c49c9f14f69cdbae3558e10f271dfbda6d182 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sat, 10 Dec 2011 01:45:03 -0200 Subject: Use better names for command-line flags. Keep old ones around for compatibility. --- src/luarocks/add.lua | 2 +- src/luarocks/admin_remove.lua | 2 +- src/luarocks/command_line.lua | 34 ++++++++++++++++++++-------------- src/luarocks/help.lua | 14 ++++++++------ src/luarocks/refresh_cache.lua | 2 +- 5 files changed, 31 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/luarocks/add.lua b/src/luarocks/add.lua index 6edfea35..9a729ada 100644 --- a/src/luarocks/add.lua +++ b/src/luarocks/add.lua @@ -101,7 +101,7 @@ function run(...) if #files < 1 then return nil, "Argument missing, see help." end - local server, server_table = cache.get_upload_server(flags["to"]) + local server, server_table = cache.get_upload_server(flags["tree"]) if not server then return nil, server_table end return add_files_to_server(not flags["no-refresh"], files, server, server_table) end diff --git a/src/luarocks/admin_remove.lua b/src/luarocks/admin_remove.lua index 1b897e7d..f1268576 100644 --- a/src/luarocks/admin_remove.lua +++ b/src/luarocks/admin_remove.lua @@ -80,7 +80,7 @@ function run(...) if #files < 1 then return nil, "Argument missing, see help." end - local server, server_table = cache.get_upload_server(flags["from"]) + local server, server_table = cache.get_upload_server(flags["server"]) if not server then return nil, server_table end return remove_files_from_server(not flags["no-refresh"], files, server, server_table) end diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 41c1c278..8fa9073c 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -57,6 +57,12 @@ function run_command(...) end local nonflags = { util.parse_flags(unpack(args)) } local flags = table.remove(nonflags, 1) + + if flags["from"] then flags["server"] = flags["from"] end + if flags["only-from"] then flags["only-server"] = flags["only-from"] end + if flags["only-sources-from"] then flags["only-sources"] = flags["only-sources-from"] end + if flags["to"] then flags["tree"] = flags["to"] end + cfg.flags = flags local command @@ -90,11 +96,11 @@ function run_command(...) flags["local"] = true end - if flags["to"] then - if flags["to"] == true then - die("Argument error: use --to=") + if flags["tree"] then + if flags["tree"] == true then + die("Argument error: use --tree=") end - local root_dir = fs.absolute_name(flags["to"]) + local root_dir = fs.absolute_name(flags["tree"]) path.use_tree(root_dir) elseif flags["local"] then path.use_tree(cfg.home_tree) @@ -116,23 +122,23 @@ function run_command(...) cfg.variables.ROCKS_TREE = cfg.rocks_dir cfg.variables.SCRIPTS_DIR = cfg.deploy_bin_dir - if flags["from"] then - if flags["from"] == true then - die("Argument error: use --from=") + if flags["server"] then + if flags["server"] == true then + die("Argument error: use --server=") end - local protocol, path = dir.split_url(flags["from"]) + local protocol, path = dir.split_url(flags["server"]) table.insert(cfg.rocks_servers, 1, protocol.."://"..path) end - if flags["only-from"] then - if flags["only-from"] == true then - die("Argument error: use --only-from=") + if flags["only-server"] then + if flags["only-server"] == true then + die("Argument error: use --only-server=") end - cfg.rocks_servers = { flags["only-from"] } + cfg.rocks_servers = { flags["only-server"] } end - if flags["only-sources-from"] then - cfg.only_sources_from = flags["only-sources-from"] + if flags["only-sources"] then + cfg.only_sources_from = flags["only-sources"] end if command ~= "help" then diff --git a/src/luarocks/help.lua b/src/luarocks/help.lua index a2e64b5d..718580ce 100644 --- a/src/luarocks/help.lua +++ b/src/luarocks/help.lua @@ -35,12 +35,14 @@ usage: ]]..program_name..[[ [--from= | --only-from=] [--to= Fetch rocks/rockspecs from this server - (takes priority over config file) ---only-from= Fetch rocks/rockspecs from this server only - (overrides any entries in the config file) ---to= Which tree to operate on. ---local Use the tree in the user's home directory. +--server= Fetch rocks/rockspecs from this server + (takes priority over config file) +--only-server= Fetch rocks/rockspecs from this server only + (overrides any entries in the config file) +--only-sources= Restrict downloads to paths matching the + given URL. +--tree= Which tree to operate on. +--local Use the tree in the user's home directory. Supported commands: ]]) diff --git a/src/luarocks/refresh_cache.lua b/src/luarocks/refresh_cache.lua index 23f86a13..2ea7e9f4 100644 --- a/src/luarocks/refresh_cache.lua +++ b/src/luarocks/refresh_cache.lua @@ -15,7 +15,7 @@ from the configuration file is used instead. function run(...) local flags = util.parse_flags(...) - local server, upload_server = cache.get_upload_server(flags["from"]) + local server, upload_server = cache.get_upload_server(flags["server"]) if not server then return nil, upload_server end local download_url = cache.get_server_urls(server, upload_server) -- cgit v1.2.3-55-g6feb