aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormpeterv <mpeterval@gmail.com>2016-03-22 11:40:34 +0300
committermpeterv <mpeterval@gmail.com>2016-03-22 11:43:29 +0300
commit0af7e42eb7814424ce8365897593abb9fc62ce14 (patch)
tree4c83ebccd859187f8d11252458f653e731124462 /src
parentb0d396b22febd4b3b717f6ddc3732c9dc57fad7c (diff)
downloadluarocks-0af7e42eb7814424ce8365897593abb9fc62ce14.tar.gz
luarocks-0af7e42eb7814424ce8365897593abb9fc62ce14.tar.bz2
luarocks-0af7e42eb7814424ce8365897593abb9fc62ce14.zip
luarocks show: split direct and indirect deps
Additionally show constraints for direct deps and versions used for all deps.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/show.lua30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/luarocks/show.lua b/src/luarocks/show.lua
index 0f29e468..ae41a513 100644
--- a/src/luarocks/show.lua
+++ b/src/luarocks/show.lua
@@ -90,6 +90,16 @@ function show.pick_installed_rock(name, version, tree)
90 return name, version, repo, repo_url 90 return name, version, repo, repo_url
91end 91end
92 92
93local function installed_rock_label(name, tree)
94 local installed, version
95 if cfg.rocks_provided[name] then
96 installed, version = true, cfg.rocks_provided[name]
97 else
98 installed, version = show.pick_installed_rock(name, nil, tree)
99 end
100 return installed and "(using "..version..")" or "(missing)"
101end
102
93--- Driver function for "show" command. 103--- Driver function for "show" command.
94-- @param name or nil: an existing package name. 104-- @param name or nil: an existing package name.
95-- @param version string or nil: a version may also be passed. 105-- @param version string or nil: a version may also be passed.
@@ -145,10 +155,26 @@ function show.run(...)
145 util.printout("\t"..mod.." ("..path.which(mod, filename, name, version, repo, manifest)..")") 155 util.printout("\t"..mod.." ("..path.which(mod, filename, name, version, repo, manifest)..")")
146 end 156 end
147 end 157 end
148 if next(minfo.dependencies) then 158 local direct_deps = {}
159 if #rockspec.dependencies > 0 then
149 util.printout() 160 util.printout()
150 util.printout("Depends on:") 161 util.printout("Depends on:")
151 util.printout("\t"..keys_as_string(minfo.dependencies, "\n\t")) 162 for _, dep in ipairs(rockspec.dependencies) do
163 direct_deps[dep.name] = true
164 util.printout("\t"..deps.show_dep(dep).." "..installed_rock_label(dep.name, flags["tree"]))
165 end
166 end
167 local has_indirect_deps
168 for dep_name in util.sortedpairs(minfo.dependencies) do
169 if not direct_deps[dep_name] then
170 if not has_indirect_deps then
171 util.printout()
172 util.printout("Indirectly pulling:")
173 has_indirect_deps = true
174 end
175
176 util.printout("\t"..dep_name.." "..installed_rock_label(dep_name, flags["tree"]))
177 end
152 end 178 end
153 util.printout() 179 util.printout()
154 end 180 end