Merge pull request #82 from hiteshjasani/master
Add command to list installed packages.
This commit is contained in:
commit
e6bdf4312c
1 changed files with 19 additions and 1 deletions
|
|
@ -16,6 +16,7 @@ type
|
||||||
TOptions = object
|
TOptions = object
|
||||||
forcePrompts: TForcePrompt
|
forcePrompts: TForcePrompt
|
||||||
queryVersions: bool
|
queryVersions: bool
|
||||||
|
queryInstalled: bool
|
||||||
action: TAction
|
action: TAction
|
||||||
config: TConfig
|
config: TConfig
|
||||||
nimbleData: PJsonNode ## Nimbledata.json
|
nimbleData: PJsonNode ## Nimbledata.json
|
||||||
|
|
@ -55,6 +56,7 @@ Commands:
|
||||||
search [--ver] pkg/tag Searches for a specified package. Search is
|
search [--ver] pkg/tag Searches for a specified package. Search is
|
||||||
performed by tag and by name.
|
performed by tag and by name.
|
||||||
list [--ver] Lists all packages.
|
list [--ver] Lists all packages.
|
||||||
|
[-i, --installed] Lists all installed packages.
|
||||||
path pkgname ... Shows absolute path to the installed packages
|
path pkgname ... Shows absolute path to the installed packages
|
||||||
specified.
|
specified.
|
||||||
|
|
||||||
|
|
@ -184,6 +186,7 @@ proc parseCmdLine(): TOptions =
|
||||||
of "accept", "y": result.forcePrompts = ForcePromptYes
|
of "accept", "y": result.forcePrompts = ForcePromptYes
|
||||||
of "reject", "n": result.forcePrompts = ForcePromptNo
|
of "reject", "n": result.forcePrompts = ForcePromptNo
|
||||||
of "ver": result.queryVersions = true
|
of "ver": result.queryVersions = true
|
||||||
|
of "installed", "i": result.queryInstalled = true
|
||||||
of cmdEnd: assert(false) # cannot happen
|
of cmdEnd: assert(false) # cannot happen
|
||||||
if result.action.typ == ActionNil:
|
if result.action.typ == ActionNil:
|
||||||
writeHelp()
|
writeHelp()
|
||||||
|
|
@ -663,6 +666,20 @@ proc list(options: TOptions) =
|
||||||
echoPackageVersions(pkg)
|
echoPackageVersions(pkg)
|
||||||
echo(" ")
|
echo(" ")
|
||||||
|
|
||||||
|
proc listInstalled(options: TOptions) =
|
||||||
|
var h = initTable[string, seq[string]]()
|
||||||
|
let pkgs = getInstalledPkgs(options.getPkgsDir())
|
||||||
|
for x in pkgs.items():
|
||||||
|
let
|
||||||
|
pName = x.pkginfo.name
|
||||||
|
pVer = x.pkginfo.version
|
||||||
|
if not h.hasKey(pName): h[pName] = @[]
|
||||||
|
var s = h[pName]
|
||||||
|
add(s, pVer)
|
||||||
|
h[pName] = s
|
||||||
|
for k in keys(h):
|
||||||
|
echo k & " [" & h[k].join(", ") & "]"
|
||||||
|
|
||||||
type VersionAndPath = tuple[version: TVersion, path: string]
|
type VersionAndPath = tuple[version: TVersion, path: string]
|
||||||
|
|
||||||
proc listPaths(options: TOptions) =
|
proc listPaths(options: TOptions) =
|
||||||
|
|
@ -814,7 +831,8 @@ proc doAction(options: TOptions) =
|
||||||
of ActionSearch:
|
of ActionSearch:
|
||||||
search(options)
|
search(options)
|
||||||
of ActionList:
|
of ActionList:
|
||||||
list(options)
|
if options.queryInstalled: listInstalled(options)
|
||||||
|
else: list(options)
|
||||||
of ActionPath:
|
of ActionPath:
|
||||||
listPaths(options)
|
listPaths(options)
|
||||||
of ActionBuild:
|
of ActionBuild:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue