Merge remote-tracking branch 'upstream/master'
Conflicts: src/nimble.nim
This commit is contained in:
commit
ceb1e48a80
6 changed files with 43 additions and 24 deletions
|
|
@ -16,6 +16,7 @@ type
|
|||
Options = object
|
||||
forcePrompts: ForcePrompt
|
||||
queryVersions: bool
|
||||
queryInstalled: bool
|
||||
action: Action
|
||||
config: Config
|
||||
nimbleData: JsonNode ## Nimbledata.json
|
||||
|
|
@ -37,6 +38,7 @@ type
|
|||
search: seq[string] # Search string.
|
||||
of actionInit:
|
||||
projName: string
|
||||
else:nil
|
||||
|
||||
ForcePrompt = enum
|
||||
dontForcePrompt, forcePromptYes, forcePromptNo
|
||||
|
|
@ -55,6 +57,7 @@ Commands:
|
|||
search [--ver] pkg/tag Searches for a specified package. Search is
|
||||
performed by tag and by name.
|
||||
list [--ver] Lists all packages.
|
||||
[-i, --installed] Lists all installed packages.
|
||||
path pkgname ... Shows absolute path to the installed packages
|
||||
specified.
|
||||
|
||||
|
|
@ -171,7 +174,7 @@ proc parseCmdLine(): Options =
|
|||
let pkgTup = (key[0 .. i-1], key[i+1 .. -1].parseVersionRange())
|
||||
result.action.packages.add(pkgTup)
|
||||
else:
|
||||
result.action.packages.add((key, VersionRangeRef(kind: verAny)))
|
||||
result.action.packages.add((key, VersionRange(kind: verAny)))
|
||||
of actionUpdate:
|
||||
result.action.optionalURL = key
|
||||
of actionSearch:
|
||||
|
|
@ -192,6 +195,7 @@ proc parseCmdLine(): Options =
|
|||
of "accept", "y": result.forcePrompts = forcePromptYes
|
||||
of "reject", "n": result.forcePrompts = forcePromptNo
|
||||
of "ver": result.queryVersions = true
|
||||
of "installed", "i": result.queryInstalled = true
|
||||
else: discard
|
||||
of cmdEnd: assert(false) # cannot happen
|
||||
if result.action.typ == actionNil:
|
||||
|
|
@ -576,7 +580,7 @@ proc getNimbleTempDir(): string =
|
|||
else:
|
||||
result.add($getpid())
|
||||
|
||||
proc downloadPkg(url: string, verRange: VersionRangeRef,
|
||||
proc downloadPkg(url: string, verRange: VersionRange,
|
||||
downMethod: DownloadMethod): string =
|
||||
let downloadDir = (getNimbleTempDir() / getDownloadDirName(url, verRange))
|
||||
createDir(downloadDir)
|
||||
|
|
@ -584,7 +588,7 @@ proc downloadPkg(url: string, verRange: VersionRangeRef,
|
|||
doDownload(url, downloadDir, verRange, downMethod)
|
||||
result = downloadDir
|
||||
|
||||
proc downloadPkg(pkg: Package, verRange: VersionRangeRef): string =
|
||||
proc downloadPkg(pkg: Package, verRange: VersionRange): string =
|
||||
let downloadDir = (getNimbleTempDir() / getDownloadDirName(pkg, verRange))
|
||||
let downMethod = pkg.downloadMethod.getDownloadMethod()
|
||||
createDir(downloadDir)
|
||||
|
|
@ -677,6 +681,20 @@ proc list(options: Options) =
|
|||
echoPackageVersions(pkg)
|
||||
echo(" ")
|
||||
|
||||
proc listInstalled(options: Options) =
|
||||
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: Version, path: string]
|
||||
|
||||
proc listPaths(options: Options) =
|
||||
|
|
@ -830,7 +848,8 @@ proc doAction(options: Options) =
|
|||
of actionSearch:
|
||||
search(options)
|
||||
of actionList:
|
||||
list(options)
|
||||
if options.queryInstalled: listInstalled(options)
|
||||
else: list(options)
|
||||
of actionPath:
|
||||
listPaths(options)
|
||||
of actionBuild:
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ proc checkUrlType*(url: string): DownloadMethod =
|
|||
proc isURL*(name: string): bool =
|
||||
name.startsWith(peg" @'://' ")
|
||||
|
||||
proc doDownload*(url: string, downloadDir: string, verRange: VersionRangeRef,
|
||||
proc doDownload*(url: string, downloadDir: string, verRange: VersionRange,
|
||||
downMethod: DownloadMethod) =
|
||||
template getLatestByTag(meth: stmt): stmt {.dirty, immediate.} =
|
||||
echo("Found tags...")
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import parsecfg, json, streams, strutils, parseutils, os
|
|||
import version, tools, nimbletypes
|
||||
type
|
||||
## Tuple containing package name and version range.
|
||||
PkgTuple* = tuple[name: string, ver: VersionRangeRef]
|
||||
PkgTuple* = tuple[name: string, ver: VersionRange]
|
||||
|
||||
PackageInfo* = object
|
||||
mypath*: string ## The path of this .nimble file
|
||||
|
|
@ -95,7 +95,7 @@ proc parseRequires(req: string): PkgTuple =
|
|||
result.ver = parseVersionRange(req[i .. -1])
|
||||
else:
|
||||
result.name = req.strip
|
||||
result.ver = VersionRangeRef(kind: verAny)
|
||||
result.ver = VersionRange(kind: verAny)
|
||||
except ParseVersionError:
|
||||
raise newException(NimbleError,
|
||||
"Unable to parse dependency version range: " & getCurrentExceptionMsg())
|
||||
|
|
@ -351,7 +351,7 @@ proc echoPackage*(pkg: Package) =
|
|||
if pkg.web.len > 0:
|
||||
echo(" website: " & pkg.web)
|
||||
|
||||
proc getDownloadDirName*(pkg: Package, verRange: VersionRangeRef): string =
|
||||
proc getDownloadDirName*(pkg: Package, verRange: VersionRange): string =
|
||||
result = pkg.name
|
||||
let verSimple = getSimpleString(verRange)
|
||||
if verSimple != "":
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ proc copyDirD*(fro, to: string): seq[string] =
|
|||
createDir(changeRoot(fro, to, path.splitFile.dir))
|
||||
result.add copyFileD(path, changeRoot(fro, to, path))
|
||||
|
||||
proc getDownloadDirName*(uri: string, verRange: VersionRangeRef): string =
|
||||
proc getDownloadDirName*(uri: string, verRange: VersionRange): string =
|
||||
## Creates a directory name based on the specified ``uri`` (url)
|
||||
result = ""
|
||||
let puri = parseUri(uri)
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -17,15 +17,15 @@ type
|
|||
verAny, # *
|
||||
verSpecial # #head
|
||||
|
||||
VersionRangeRef* = ref VersionRange
|
||||
VersionRange* = object
|
||||
VersionRange* = ref VersionRangeObj
|
||||
VersionRangeObj = object
|
||||
case kind*: VersionRangeEnum
|
||||
of verLater, verEarlier, verEqLater, verEqEarlier, verEq:
|
||||
ver*: Version
|
||||
of verSpecial:
|
||||
spe*: Special
|
||||
of verIntersect:
|
||||
verILeft, verIRight: VersionRangeRef
|
||||
verILeft, verIRight: VersionRange
|
||||
of verAny:
|
||||
nil
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ proc `==`*(spe: Special, spe2: Special): bool =
|
|||
proc `<=`*(ver: Version, ver2: Version): bool =
|
||||
return (ver == ver2) or (ver < ver2)
|
||||
|
||||
proc withinRange*(ver: Version, ran: VersionRangeRef): bool =
|
||||
proc withinRange*(ver: Version, ran: VersionRange): bool =
|
||||
case ran.kind
|
||||
of verLater:
|
||||
return ver > ran.ver
|
||||
|
|
@ -99,7 +99,7 @@ proc withinRange*(ver: Version, ran: VersionRangeRef): bool =
|
|||
of verAny:
|
||||
return true
|
||||
|
||||
proc withinRange*(spe: Special, ran: VersionRangeRef): bool =
|
||||
proc withinRange*(spe: Special, ran: VersionRange): bool =
|
||||
case ran.kind
|
||||
of verLater, verEarlier, verEqLater, verEqEarlier, verEq, verIntersect:
|
||||
return false
|
||||
|
|
@ -108,13 +108,13 @@ proc withinRange*(spe: Special, ran: VersionRangeRef): bool =
|
|||
of verAny:
|
||||
return true
|
||||
|
||||
proc contains*(ran: VersionRangeRef, ver: Version): bool =
|
||||
proc contains*(ran: VersionRange, ver: Version): bool =
|
||||
return withinRange(ver, ran)
|
||||
|
||||
proc contains*(ran: VersionRangeRef, spe: Special): bool =
|
||||
proc contains*(ran: VersionRange, spe: Special): bool =
|
||||
return withinRange(spe, ran)
|
||||
|
||||
proc makeRange*(version: string, op: string): VersionRangeRef =
|
||||
proc makeRange*(version: string, op: string): VersionRange =
|
||||
new(result)
|
||||
if version == "":
|
||||
raise newException(ParseVersionError,
|
||||
|
|
@ -134,7 +134,7 @@ proc makeRange*(version: string, op: string): VersionRangeRef =
|
|||
raise newException(ParseVersionError, "Invalid operator: " & op)
|
||||
result.ver = Version(version)
|
||||
|
||||
proc parseVersionRange*(s: string): VersionRangeRef =
|
||||
proc parseVersionRange*(s: string): VersionRange =
|
||||
# >= 1.5 & <= 1.8
|
||||
new(result)
|
||||
if s[0] == '#':
|
||||
|
|
@ -184,7 +184,7 @@ proc parseVersionRange*(s: string): VersionRangeRef =
|
|||
"Unexpected char in version range: " & s[i])
|
||||
inc(i)
|
||||
|
||||
proc `$`*(verRange: VersionRangeRef): string =
|
||||
proc `$`*(verRange: VersionRange): string =
|
||||
case verRange.kind
|
||||
of verLater:
|
||||
result = "> "
|
||||
|
|
@ -205,7 +205,7 @@ proc `$`*(verRange: VersionRangeRef): string =
|
|||
|
||||
result.add(string(verRange.ver))
|
||||
|
||||
proc getSimpleString*(verRange: VersionRangeRef): string =
|
||||
proc getSimpleString*(verRange: VersionRange): string =
|
||||
## Gets a string with no special symbols and spaces. Used for dir name
|
||||
## creation in tools.nim
|
||||
case verRange.kind
|
||||
|
|
@ -219,21 +219,21 @@ proc getSimpleString*(verRange: VersionRangeRef): string =
|
|||
of verAny:
|
||||
result = ""
|
||||
|
||||
proc newVRAny*(): VersionRangeRef =
|
||||
proc newVRAny*(): VersionRange =
|
||||
new(result)
|
||||
result.kind = verAny
|
||||
|
||||
proc newVREarlier*(ver: string): VersionRangeRef =
|
||||
proc newVREarlier*(ver: string): VersionRange =
|
||||
new(result)
|
||||
result.kind = verEarlier
|
||||
result.ver = newVersion(ver)
|
||||
|
||||
proc newVREq*(ver: string): VersionRangeRef =
|
||||
proc newVREq*(ver: string): VersionRange =
|
||||
new(result)
|
||||
result.kind = verEq
|
||||
result.ver = newVersion(ver)
|
||||
|
||||
proc findLatest*(verRange: VersionRangeRef,
|
||||
proc findLatest*(verRange: VersionRange,
|
||||
versions: Table[Version, string]): tuple[ver: Version, tag: string] =
|
||||
result = (newVersion(""), "")
|
||||
for ver, tag in versions:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue