diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/show.lua | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/luarocks/show.lua b/src/luarocks/show.lua index 08b2673f..ae41a513 100644 --- a/src/luarocks/show.lua +++ b/src/luarocks/show.lua | |||
| @@ -28,7 +28,9 @@ With these flags, return only the desired information: | |||
| 28 | ]] | 28 | ]] |
| 29 | 29 | ||
| 30 | local function keys_as_string(t, sep) | 30 | local function keys_as_string(t, sep) |
| 31 | return table.concat(util.keys(t), sep or " ") | 31 | local keys = util.keys(t) |
| 32 | table.sort(keys) | ||
| 33 | return table.concat(keys, sep or " ") | ||
| 32 | end | 34 | end |
| 33 | 35 | ||
| 34 | local function word_wrap(line) | 36 | local function word_wrap(line) |
| @@ -88,6 +90,16 @@ function show.pick_installed_rock(name, version, tree) | |||
| 88 | return name, version, repo, repo_url | 90 | return name, version, repo, repo_url |
| 89 | end | 91 | end |
| 90 | 92 | ||
| 93 | local 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)" | ||
| 101 | end | ||
| 102 | |||
| 91 | --- Driver function for "show" command. | 103 | --- Driver function for "show" command. |
| 92 | -- @param name or nil: an existing package name. | 104 | -- @param name or nil: an existing package name. |
| 93 | -- @param version string or nil: a version may also be passed. | 105 | -- @param version string or nil: a version may also be passed. |
| @@ -143,10 +155,26 @@ function show.run(...) | |||
| 143 | 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)..")") |
| 144 | end | 156 | end |
| 145 | end | 157 | end |
| 146 | if next(minfo.dependencies) then | 158 | local direct_deps = {} |
| 159 | if #rockspec.dependencies > 0 then | ||
| 147 | util.printout() | 160 | util.printout() |
| 148 | util.printout("Depends on:") | 161 | util.printout("Depends on:") |
| 149 | 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 | ||
| 150 | end | 178 | end |
| 151 | util.printout() | 179 | util.printout() |
| 152 | end | 180 | end |
