aboutsummaryrefslogtreecommitdiff
path: root/src/luarocks/command_line.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/luarocks/command_line.lua')
-rw-r--r--src/luarocks/command_line.lua18
1 files changed, 15 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)
24end 24end
25 25
26local 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)
36end
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])