From 3bc775bb10f9cec6c4c66b1221ece63077ea6ea7 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 23 Dec 2013 18:12:35 -0200 Subject: Make sure value of tree is propagated correctly to commands. --- src/luarocks/command_line.lua | 18 +++++++++++++++--- src/luarocks/help.lua | 9 +++++++++ src/luarocks/purge.lua | 3 +++ 3 files changed, 27 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 059b7a1c..b98084e0 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -23,6 +23,18 @@ local function die(message) os.exit(1) end +local function replace_tree(flags, args, tree) + local tree = dir.normalize(tree) + flags["tree"] = tree + for i = 1, #args do + if args[i]:match("%-%-tree=") then + args[i] = "--tree="..tree + break + end + end + path.use_tree(tree) +end + --- Main command-line processor. -- Parses input arguments and calls the appropriate driver function -- to execute the action requested on the command-line, forwarding @@ -110,7 +122,7 @@ function run_command(...) if not tree.root then die("Configuration error: tree '"..tree.name.."' has no 'root' field.") end - path.use_tree(dir.normalize(tree.root)) + replace_tree(flags, args, tree.root) named = true break end @@ -118,10 +130,10 @@ function run_command(...) if not named then local fs = require("luarocks.fs") local root_dir = fs.absolute_name(flags["tree"]) - path.use_tree(root_dir) + replace_tree(flags, args, root_dir) end elseif flags["local"] then - path.use_tree(cfg.home_tree) + replace_tree(flags, args, cfg.home_tree) else local trees = cfg.rocks_trees path.use_tree(trees[#trees]) diff --git a/src/luarocks/help.lua b/src/luarocks/help.lua index d9be46fc..33c684ad 100644 --- a/src/luarocks/help.lua +++ b/src/luarocks/help.lua @@ -87,6 +87,15 @@ function run(...) else util.printout("\tUser configuration file disabled in this LuaRocks installation.\n") end + util.printout("\tRocks trees in use: ") + for _, tree in ipairs(cfg.rocks_trees) do + if type(tree) == "string" then + util.printout("\t\t"..tree) + else + local name = tree.name and " (\""..tree.name.."\")" or "" + util.printout("\t\t"..tree.root..name) + end + end else command = command:gsub("-", "_") if commands[command] then diff --git a/src/luarocks/purge.lua b/src/luarocks/purge.lua index e76a82e9..285c0f34 100644 --- a/src/luarocks/purge.lua +++ b/src/luarocks/purge.lua @@ -41,6 +41,9 @@ function run(...) local results = {} local query = search.make_query("") query.exact_name = false + if not fs.is_dir(tree) then + return nil, "Directory not found: "..tree + end search.manifest_search(results, path.rocks_dir(tree), query) local sort = function(a,b) return deps.compare_versions(b,a) end -- cgit v1.2.3-55-g6feb