@@ -57,7 +57,7 @@ proc displaySatisfiedMsg(solvedPkgs: seq[SolvedPackage], pkgToInstall: seq[(stri
5757 for pkg in solvedPkgs:
5858 if pkg.pkgName notin pkgToInstall.mapIt (it[0 ]):
5959 for req in pkg.requirements:
60- displayInfo (pkgDepsAlreadySatisfiedMsg (req))
60+ displayInfo (pkgDepsAlreadySatisfiedMsg (req), MediumPriority )
6161
6262proc displayUsingSpecialVersionWarning (solvedPkgs: seq [SolvedPackage ], options: Options ) =
6363 var messages = newSeq [string ]()
@@ -182,7 +182,7 @@ proc processFreeDependencies(pkgInfo: PackageInfo,
182182
183183 display (" Verifying" , " dependencies for $1@$2" %
184184 [pkgInfo.basicInfo.name, $ pkgInfo.basicInfo.version],
185- priority = HighPriority )
185+ priority = MediumPriority )
186186
187187 var reverseDependencies: seq [PackageBasicInfo ] = @ []
188188
@@ -208,7 +208,7 @@ proc processFreeDependencies(pkgInfo: PackageInfo,
208208 resolvedDep.name)
209209
210210 if not found:
211- display (" Installing" , $ resolvedDep, priority = HighPriority )
211+ display (" Installing" , $ resolvedDep, priority = MediumPriority )
212212 let toInstall = @ [(resolvedDep.name, resolvedDep.ver)]
213213 let (packages, installedPkg) = install (toInstall, options,
214214 doPrompt = false , first = false , fromLockFile = false ,
@@ -230,7 +230,7 @@ proc processFreeDependencies(pkgInfo: PackageInfo,
230230 # This package has been installed so we add it to our pkgList.
231231 pkgList.add pkg
232232 else :
233- displayInfo (pkgDepsAlreadySatisfiedMsg (dep))
233+ displayInfo (pkgDepsAlreadySatisfiedMsg (dep), MediumPriority )
234234 result .incl pkg
235235 # Process the dependencies of this dependency.
236236 let fullInfo = pkg.toFullInfo (options)
@@ -512,13 +512,13 @@ proc installFromDir(dir: string, requestedVer: VersionRange, options: Options,
512512
513513 display (" Installing" , " $1@$2" %
514514 [pkginfo.basicInfo.name, $ pkginfo.basicInfo.version],
515- priority = HighPriority )
515+ priority = MediumPriority )
516516
517517 let oldPkg = pkgInfo.packageExists (options)
518518 if oldPkg.isSome:
519519 # In the case we already have the same package in the cache then only merge
520520 # the new package special versions to the old one.
521- displayWarning (pkgAlreadyExistsInTheCacheMsg (pkgInfo))
521+ displayWarning (pkgAlreadyExistsInTheCacheMsg (pkgInfo), MediumPriority )
522522 if not options.useSatSolver: # The dep path is not created when using the sat solver as packages are collected upfront
523523 var oldPkg = oldPkg.get
524524 oldPkg.metaData.specialVersions.incl pkgInfo.metaData.specialVersions
@@ -615,7 +615,7 @@ proc installFromDir(dir: string, requestedVer: VersionRange, options: Options,
615615
616616 pkgInfo.isInstalled = true
617617
618- displaySuccess (pkgInstalledMsg (pkgInfo.basicInfo.name))
618+ displaySuccess (pkgInstalledMsg (pkgInfo.basicInfo.name), MediumPriority )
619619
620620 result .deps.incl pkgInfo
621621 result .pkg = pkgInfo
@@ -1023,7 +1023,7 @@ proc search(options: Options) =
10231023 var found = false
10241024 template onFound {.dirty .} =
10251025 echoPackage (pkg)
1026- if pkg.alias.len == 0 and options.queryVersions :
1026+ if pkg.alias.len == 0 and options.action.showSearchVersions :
10271027 echoPackageVersions (pkg)
10281028 echo (" " )
10291029 found = true
@@ -1049,29 +1049,61 @@ proc list(options: Options) =
10491049 let pkgList = getPackageList (options)
10501050 for pkg in pkgList:
10511051 echoPackage (pkg)
1052- if pkg.alias.len == 0 and options.queryVersions :
1052+ if pkg.alias.len == 0 and options.action.showListVersions :
10531053 echoPackageVersions (pkg)
10541054 echo (" " )
10551055
1056+ proc listNimBinaries (options: Options ) =
1057+ let nimBininstalledPkgs = getInstalledPkgsMin (options.nimBinariesDir, options)
1058+ displayFormatted (Message , " nim" )
1059+ displayFormatted (Hint , " \n " )
1060+ for idx, pkg in nimBininstalledPkgs:
1061+ assert pkg.basicInfo.name == " nim"
1062+ if idx == nimBininstalledPkgs.len () - 1 :
1063+ displayFormatted (Hint , " └── " )
1064+ else :
1065+ displayFormatted (Hint , " ├── " )
1066+ displayFormatted (Success , " @" & $ pkg.basicInfo.version)
1067+ displayFormatted (Hint , " " )
1068+ displayFormatted (Details , fmt" ({ pkg.myPath.splitPath ().head} ) " )
1069+ displayFormatted (Hint , " \n " )
1070+ displayFormatted (Hint , " \n " )
1071+
10561072proc listInstalled (options: Options ) =
10571073 type
10581074 VersionChecksumTuple = tuple [version: Version , checksum: Sha1Hash ]
1059- var h : OrderedTable [string , seq [VersionChecksumTuple ]]
1075+ var vers : OrderedTable [string , seq [VersionChecksumTuple ]]
10601076 let pkgs = getInstalledPkgsMin (options.getPkgsDir (), options)
10611077 for pkg in pkgs:
10621078 let
10631079 pName = pkg.basicInfo.name
10641080 pVersion = pkg.basicInfo.version
10651081 pChecksum = pkg.basicInfo.checksum
1066- if not h .hasKey (pName): h [pName] = @ []
1067- var s = h [pName]
1082+ if not vers .hasKey (pName): vers [pName] = @ []
1083+ var s = vers [pName]
10681084 add (s, (pVersion, pChecksum))
1069- h [pName] = s
1085+ vers [pName] = s
10701086
1071- h .sort (proc (a, b: (string , seq [VersionChecksumTuple ])): int =
1087+ vers .sort (proc (a, b: (string , seq [VersionChecksumTuple ])): int =
10721088 cmpIgnoreCase (a[0 ], b[0 ]))
1073- for k in keys (h):
1074- echo k & " [" & h [k].join (" , " ) & " ]"
1089+
1090+ displayInfo (" Package list format: {PackageName} " )
1091+ displayInfo (" {PackageName} " )
1092+ displayInfo (" {Version} ({CheckSum})" )
1093+ for k in keys (vers):
1094+ displayFormatted (Message , k)
1095+ displayFormatted (Hint , " \n " )
1096+ if options.action.showListVersions:
1097+ for idx, item in vers[k]:
1098+ if idx == vers[k].len () - 1 :
1099+ displayFormatted (Hint , " └── " )
1100+ else :
1101+ displayFormatted (Hint , " ├── " )
1102+ displayFormatted (Success , " @" , $ item.version)
1103+ displayFormatted (Hint , " " )
1104+ displayFormatted (Details , fmt" ({ item.checksum} ) " )
1105+ displayFormatted (Hint , " \n " )
1106+ # " [" & vers[k].join(", ") & "]"
10751107
10761108type VersionAndPath = tuple [version: Version , path: string ]
10771109
@@ -1925,9 +1957,25 @@ proc lock(options: Options) =
19251957 updateSyncFile (pkgInfo, options)
19261958 displayLockOperationFinish (lockExists)
19271959
1928- proc depsTree (options: Options ) =
1960+ proc depsPrint (options: Options ,
1961+ pkgInfo: PackageInfo ,
1962+ dependencies: seq [PackageInfo ],
1963+ errors: ValidationErrors ) =
19291964 # # Prints the dependency tree
19301965
1966+ if options.action.format == " json" :
1967+ if options.action.depsAction == " inverted" :
1968+ raise nimbleError (" Deps JSON format does not support inverted tree" )
1969+ echo (% depsRecursive (pkgInfo, dependencies, errors)).pretty
1970+ elif options.action.depsAction == " inverted" :
1971+ printDepsHumanReadableInverted (pkgInfo, dependencies, errors)
1972+ elif options.action.depsAction == " tree" :
1973+ printDepsHumanReadable (pkgInfo, dependencies, errors)
1974+ else :
1975+ printDepsHumanReadable (pkgInfo, dependencies, errors, true )
1976+
1977+ proc deps (options: Options ) =
1978+ # # handles deps actions
19311979 let pkgInfo = getPkgInfo (getCurrentDir (), options)
19321980
19331981 var errors = validateDevModeDepsWorkingCopiesBeforeLock (pkgInfo, options)
@@ -1942,12 +1990,10 @@ proc depsTree(options: Options) =
19421990 if not dependencyGraph.contains name:
19431991 errors.del name
19441992
1945- if options.action.format == " json" :
1946- echo (% depsRecursive (pkgInfo, dependencies, errors)).pretty
1947- elif options.action.format == " inverted" :
1948- printDepsHumanReadableInverted (pkgInfo, dependencies, errors)
1993+ if options.action.depsAction in [" " , " tree" , " inverted" ]:
1994+ depsPrint (options, pkgInfo, dependencies, errors)
19491995 else :
1950- printDepsHumanReadable (pkgInfo, dependencies, errors )
1996+ raise nimbleError ( " Unknown deps flag: " & options.action.depsAction )
19511997
19521998proc syncWorkingCopy (name: string , path: Path , dependentPkg: PackageInfo ,
19531999 options: Options ) =
@@ -2312,8 +2358,12 @@ proc doAction(options: var Options) =
23122358 of actionSearch:
23132359 search (options)
23142360 of actionList:
2315- if options.queryInstalled: listInstalled (options)
2316- else : list (options)
2361+ if options.action.onlyInstalled:
2362+ listInstalled (options)
2363+ elif options.action.onlyNimBinaries:
2364+ listNimBinaries (options)
2365+ else :
2366+ list (options)
23172367 of actionPath:
23182368 listPaths (options)
23192369 of actionBuild:
@@ -2331,7 +2381,10 @@ proc doAction(options: var Options) =
23312381 init (options)
23322382 of actionPublish:
23332383 var pkgInfo = getPkgInfo (getCurrentDir (), options)
2334- publish (pkgInfo, options)
2384+ if options.action.publishAction == " tags" :
2385+ publishTags (pkgInfo, options)
2386+ else :
2387+ publish (pkgInfo, options)
23352388 of actionDump:
23362389 dump (options)
23372390 of actionTasks:
@@ -2343,7 +2396,7 @@ proc doAction(options: var Options) =
23432396 of actionLock:
23442397 lock (options)
23452398 of actionDeps:
2346- depsTree (options)
2399+ deps (options)
23472400 of actionSync:
23482401 sync (options)
23492402 of actionSetup:
@@ -2493,8 +2546,8 @@ when isMainModule:
24932546 var opt: Options
24942547 try :
24952548 opt = parseCmdLine ()
2496- opt.setNimbleDir
2497- opt.loadNimbleData
2549+ opt.setNimbleDir ()
2550+ opt.loadNimbleData ()
24982551 if opt.action.typ in {actionTasks, actionRun, actionBuild, actionCompile, actionDevelop}:
24992552 # Implicitly disable package validation for these commands.
25002553 opt.disableValidation = true
0 commit comments