diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2013-12-23 18:12:35 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-12-23 18:12:35 -0200 |
commit | 3bc775bb10f9cec6c4c66b1221ece63077ea6ea7 (patch) | |
tree | f6115bebcb6820befc8356b7072e5dfa5d3a1fe9 | |
parent | 786b6a19030ce533268c99f65b396af2ab1efe28 (diff) | |
download | luarocks-3bc775bb10f9cec6c4c66b1221ece63077ea6ea7.tar.gz luarocks-3bc775bb10f9cec6c4c66b1221ece63077ea6ea7.tar.bz2 luarocks-3bc775bb10f9cec6c4c66b1221ece63077ea6ea7.zip |
Make sure value of tree is propagated correctly to commands.
-rw-r--r-- | src/luarocks/command_line.lua | 18 | ||||
-rw-r--r-- | src/luarocks/help.lua | 9 | ||||
-rw-r--r-- | src/luarocks/purge.lua | 3 |
3 files changed, 27 insertions, 3 deletions
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) | |||
23 | os.exit(1) | 23 | os.exit(1) |
24 | end | 24 | end |
25 | 25 | ||
26 | local function replace_tree(flags, args, tree) | ||
27 | local tree = dir.normalize(tree) | ||
28 | flags["tree"] = tree | ||
29 | for i = 1, #args do | ||
30 | if args[i]:match("%-%-tree=") then | ||
31 | args[i] = "--tree="..tree | ||
32 | break | ||
33 | end | ||
34 | end | ||
35 | path.use_tree(tree) | ||
36 | end | ||
37 | |||
26 | --- Main command-line processor. | 38 | --- Main command-line processor. |
27 | -- Parses input arguments and calls the appropriate driver function | 39 | -- Parses input arguments and calls the appropriate driver function |
28 | -- to execute the action requested on the command-line, forwarding | 40 | -- to execute the action requested on the command-line, forwarding |
@@ -110,7 +122,7 @@ function run_command(...) | |||
110 | if not tree.root then | 122 | if not tree.root then |
111 | die("Configuration error: tree '"..tree.name.."' has no 'root' field.") | 123 | die("Configuration error: tree '"..tree.name.."' has no 'root' field.") |
112 | end | 124 | end |
113 | path.use_tree(dir.normalize(tree.root)) | 125 | replace_tree(flags, args, tree.root) |
114 | named = true | 126 | named = true |
115 | break | 127 | break |
116 | end | 128 | end |
@@ -118,10 +130,10 @@ function run_command(...) | |||
118 | if not named then | 130 | if not named then |
119 | local fs = require("luarocks.fs") | 131 | local fs = require("luarocks.fs") |
120 | local root_dir = fs.absolute_name(flags["tree"]) | 132 | local root_dir = fs.absolute_name(flags["tree"]) |
121 | path.use_tree(root_dir) | 133 | replace_tree(flags, args, root_dir) |
122 | end | 134 | end |
123 | elseif flags["local"] then | 135 | elseif flags["local"] then |
124 | path.use_tree(cfg.home_tree) | 136 | replace_tree(flags, args, cfg.home_tree) |
125 | else | 137 | else |
126 | local trees = cfg.rocks_trees | 138 | local trees = cfg.rocks_trees |
127 | path.use_tree(trees[#trees]) | 139 | 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(...) | |||
87 | else | 87 | else |
88 | util.printout("\tUser configuration file disabled in this LuaRocks installation.\n") | 88 | util.printout("\tUser configuration file disabled in this LuaRocks installation.\n") |
89 | end | 89 | end |
90 | util.printout("\tRocks trees in use: ") | ||
91 | for _, tree in ipairs(cfg.rocks_trees) do | ||
92 | if type(tree) == "string" then | ||
93 | util.printout("\t\t"..tree) | ||
94 | else | ||
95 | local name = tree.name and " (\""..tree.name.."\")" or "" | ||
96 | util.printout("\t\t"..tree.root..name) | ||
97 | end | ||
98 | end | ||
90 | else | 99 | else |
91 | command = command:gsub("-", "_") | 100 | command = command:gsub("-", "_") |
92 | if commands[command] then | 101 | 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(...) | |||
41 | local results = {} | 41 | local results = {} |
42 | local query = search.make_query("") | 42 | local query = search.make_query("") |
43 | query.exact_name = false | 43 | query.exact_name = false |
44 | if not fs.is_dir(tree) then | ||
45 | return nil, "Directory not found: "..tree | ||
46 | end | ||
44 | search.manifest_search(results, path.rocks_dir(tree), query) | 47 | search.manifest_search(results, path.rocks_dir(tree), query) |
45 | 48 | ||
46 | local sort = function(a,b) return deps.compare_versions(b,a) end | 49 | local sort = function(a,b) return deps.compare_versions(b,a) end |