Version querying is now disabled by default.
This commit is contained in:
parent
93a11fc9b9
commit
1646f45111
3 changed files with 43 additions and 28 deletions
42
babel.nim
42
babel.nim
|
|
@ -8,6 +8,7 @@ import packageinfo, version, common, tools, download, algorithm
|
||||||
type
|
type
|
||||||
TOptions = object
|
TOptions = object
|
||||||
forcePrompts: TForcePrompt
|
forcePrompts: TForcePrompt
|
||||||
|
queryVersions: bool
|
||||||
action: TAction
|
action: TAction
|
||||||
|
|
||||||
TActionType = enum
|
TActionType = enum
|
||||||
|
|
@ -33,18 +34,23 @@ const
|
||||||
Usage: babel COMMAND [opts]
|
Usage: babel COMMAND [opts]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
install [pkgname, ...] Installs a list of packages.
|
install [pkgname, ...] Installs a list of packages.
|
||||||
build Builds a package.
|
build Builds a package.
|
||||||
update [url] Updates package list. A package list URL can be optionally specified.
|
update [url] Updates package list. A package list URL can
|
||||||
search pkg/tag Searches for a specified package. Search is performed by tag and by name.
|
be optionally specified.
|
||||||
list Lists all packages.
|
search [--ver] pkg/tag Searches for a specified package. Search is
|
||||||
path [pkgname, ...] Shows absolute path to the installed packages.
|
performed by tag and by name.
|
||||||
|
list [--ver] Lists all packages.
|
||||||
|
path pkgname ... Shows absolute path to the installed packages
|
||||||
|
specified.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, -help Print this help message.
|
-h, --help Print this help message.
|
||||||
-v, -version Print version information.
|
-v, --version Print version information.
|
||||||
-y, -accept Accept all interactive prompts.
|
-y, --accept Accept all interactive prompts.
|
||||||
-n, -reject Reject all interactive prompts.
|
-n, --reject Reject all interactive prompts.
|
||||||
|
--ver Query remote server for package version
|
||||||
|
information when searching or listing packages
|
||||||
"""
|
"""
|
||||||
babelVersion = "0.1.0"
|
babelVersion = "0.1.0"
|
||||||
defaultPackageURL = "https://github.com/nimrod-code/packages/raw/master/packages.json"
|
defaultPackageURL = "https://github.com/nimrod-code/packages/raw/master/packages.json"
|
||||||
|
|
@ -99,6 +105,7 @@ proc parseCmdLine(): TOptions =
|
||||||
of "version", "v": writeVersion()
|
of "version", "v": writeVersion()
|
||||||
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 cmdEnd: assert(false) # cannot happen
|
of cmdEnd: assert(false) # cannot happen
|
||||||
if result.action.typ == ActionNil:
|
if result.action.typ == ActionNil:
|
||||||
writeHelp()
|
writeHelp()
|
||||||
|
|
@ -351,13 +358,12 @@ proc build(options: TOptions) =
|
||||||
let paths = processDeps(pkginfo, options)
|
let paths = processDeps(pkginfo, options)
|
||||||
buildFromDir(pkgInfo, paths)
|
buildFromDir(pkgInfo, paths)
|
||||||
|
|
||||||
proc search(action: TAction) =
|
proc search(options: TOptions) =
|
||||||
## Searches for matches in ``action.search``.
|
## Searches for matches in ``options.action.search``.
|
||||||
##
|
##
|
||||||
## Searches are done in a case insensitive way making all strings lower case.
|
## Searches are done in a case insensitive way making all strings lower case.
|
||||||
## This requires the input search to already be lower case.
|
assert options.action.typ == ActionSearch
|
||||||
assert action.typ == ActionSearch
|
if options.action.search == @[]:
|
||||||
if action.search == @[]:
|
|
||||||
raise newException(EBabel, "Please specify a search string.")
|
raise newException(EBabel, "Please specify a search string.")
|
||||||
if not existsFile(babelDir / "packages.json"):
|
if not existsFile(babelDir / "packages.json"):
|
||||||
raise newException(EBabel, "Please run babel update.")
|
raise newException(EBabel, "Please run babel update.")
|
||||||
|
|
@ -365,12 +371,14 @@ proc search(action: TAction) =
|
||||||
var found = false
|
var found = false
|
||||||
template onFound: stmt =
|
template onFound: stmt =
|
||||||
echoPackage(pkg)
|
echoPackage(pkg)
|
||||||
|
if options.queryVersions:
|
||||||
|
echoPackageVersions(pkg)
|
||||||
echo(" ")
|
echo(" ")
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
|
|
||||||
for pkg in pkgList:
|
for pkg in pkgList:
|
||||||
for word in action.search:
|
for word in options.action.search:
|
||||||
# Search by name.
|
# Search by name.
|
||||||
if word.toLower() in pkg.name.toLower():
|
if word.toLower() in pkg.name.toLower():
|
||||||
onFound()
|
onFound()
|
||||||
|
|
@ -432,7 +440,7 @@ proc doAction(options: TOptions) =
|
||||||
# TODO: Allow user to specify version.
|
# TODO: Allow user to specify version.
|
||||||
install(options.action.optionalName, PVersionRange(kind: verAny), options)
|
install(options.action.optionalName, PVersionRange(kind: verAny), options)
|
||||||
of ActionSearch:
|
of ActionSearch:
|
||||||
search(options.action)
|
search(options)
|
||||||
of ActionList:
|
of ActionList:
|
||||||
list()
|
list()
|
||||||
of ActionPath:
|
of ActionPath:
|
||||||
|
|
|
||||||
20
download.nim
20
download.nim
|
|
@ -152,23 +152,21 @@ proc doDownload*(pkg: TPackage, downloadDir: string, verRange: PVersionRange) =
|
||||||
"Git HEAD also does not satisfy version range: " & $verRange)
|
"Git HEAD also does not satisfy version range: " & $verRange)
|
||||||
# We use GIT HEAD if it satisfies our ver range
|
# We use GIT HEAD if it satisfies our ver range
|
||||||
|
|
||||||
proc echoPackage*(pkg: TPackage) =
|
proc echoPackageVersions*(pkg: TPackage) =
|
||||||
echo(pkg.name & ":")
|
|
||||||
echo(" url: " & pkg.url & " (" & pkg.downloadMethod & ")")
|
|
||||||
echo(" tags: " & pkg.tags.join(", "))
|
|
||||||
echo(" description: " & pkg.description)
|
|
||||||
echo(" license: " & pkg.license)
|
|
||||||
if pkg.web.len > 0:
|
|
||||||
echo(" website: " & pkg.web)
|
|
||||||
let downMethod = pkg.downloadMethod.getDownloadMethod()
|
let downMethod = pkg.downloadMethod.getDownloadMethod()
|
||||||
case downMethod
|
case downMethod
|
||||||
of TDownloadMethod.Git:
|
of TDownloadMethod.Git:
|
||||||
try:
|
try:
|
||||||
let versions = getTagsListRemote(pkg.url, downMethod).getVersionList()
|
let versions = getTagsListRemote(pkg.url, downMethod).getVersionList()
|
||||||
if versions.len > 0:
|
if versions.len > 0:
|
||||||
echo(" versions: ")
|
var vstr = ""
|
||||||
for k, ver in versions:
|
var i = 0
|
||||||
echo " ", ver
|
for v in values(versions):
|
||||||
|
if i != 0:
|
||||||
|
vstr.add(", ")
|
||||||
|
vstr.add(v)
|
||||||
|
i.inc
|
||||||
|
echo(" versions: " & vstr)
|
||||||
else:
|
else:
|
||||||
echo(" versions: (No versions tagged in the remote repository)")
|
echo(" versions: (No versions tagged in the remote repository)")
|
||||||
except EOS:
|
except EOS:
|
||||||
|
|
|
||||||
|
|
@ -264,3 +264,12 @@ proc getRealDir*(pkgInfo: TPackageInfo): string =
|
||||||
result = pkgInfo.mypath.splitFile.dir / pkgInfo.srcDir
|
result = pkgInfo.mypath.splitFile.dir / pkgInfo.srcDir
|
||||||
else:
|
else:
|
||||||
result = pkgInfo.mypath.splitFile.dir
|
result = pkgInfo.mypath.splitFile.dir
|
||||||
|
|
||||||
|
proc echoPackage*(pkg: TPackage) =
|
||||||
|
echo(pkg.name & ":")
|
||||||
|
echo(" url: " & pkg.url & " (" & pkg.downloadMethod & ")")
|
||||||
|
echo(" tags: " & pkg.tags.join(", "))
|
||||||
|
echo(" description: " & pkg.description)
|
||||||
|
echo(" license: " & pkg.license)
|
||||||
|
if pkg.web.len > 0:
|
||||||
|
echo(" website: " & pkg.web)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue