Merge branch 'pr_fix_multiline_config_files' of git://github.com/gradha/babel into gradha-pr_fix_multiline_config_files
Conflicts: readme.markdown
This commit is contained in:
commit
9409b6e9c1
3 changed files with 31 additions and 9 deletions
|
|
@ -54,6 +54,11 @@ license = "MIT"
|
||||||
|
|
||||||
SkipDirs = "SomeDir" ; ./SomeDir will not be installed
|
SkipDirs = "SomeDir" ; ./SomeDir will not be installed
|
||||||
SkipFiles = "file.txt,file2.txt" ; ./{file.txt, file2.txt} will not be installed
|
SkipFiles = "file.txt,file2.txt" ; ./{file.txt, file2.txt} will not be installed
|
||||||
|
SkipFiles = """
|
||||||
|
foo.txt
|
||||||
|
foo2.rst
|
||||||
|
foo3.md
|
||||||
|
""" ; Listing the files on multiple lines also works.
|
||||||
|
|
||||||
[Deps]
|
[Deps]
|
||||||
Requires: "nimrod >= 0.9.2"
|
Requires: "nimrod >= 0.9.2"
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,23 @@ proc parseRequires(req: string): tuple[name: string, ver: PVersionRange] =
|
||||||
except EParseVersion:
|
except EParseVersion:
|
||||||
quit("Unable to parse dependency version range: " & getCurrentExceptionMsg())
|
quit("Unable to parse dependency version range: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
|
proc multiSplit(s: string): seq[string] =
|
||||||
|
## Returns ``s`` split by newline and comma characters.
|
||||||
|
##
|
||||||
|
## Before returning, all individual entries are stripped of whitespace and
|
||||||
|
## also empty entries are purged from the list. If after all the cleanups are
|
||||||
|
## done no entries are found in the list, the proc returns a sequence with
|
||||||
|
## the original string as the only entry.
|
||||||
|
result = split(s, {char(0x0A), char(0x0D), ','})
|
||||||
|
map(result, proc(x: var string) = x = x.strip())
|
||||||
|
for i in countdown(result.len()-1, 0):
|
||||||
|
if len(result[i]) < 1:
|
||||||
|
result.del(i)
|
||||||
|
# Huh, nothing to return? Return given input.
|
||||||
|
if len(result) < 1:
|
||||||
|
return @[s]
|
||||||
|
|
||||||
|
|
||||||
proc readPackageInfo*(path: string): TPackageInfo =
|
proc readPackageInfo*(path: string): TPackageInfo =
|
||||||
result = initPackageInfo()
|
result = initPackageInfo()
|
||||||
result.mypath = path
|
result.mypath = path
|
||||||
|
|
@ -104,19 +121,19 @@ proc readPackageInfo*(path: string): TPackageInfo =
|
||||||
of "license": result.license = ev.value
|
of "license": result.license = ev.value
|
||||||
of "srcdir": result.srcDir = ev.value
|
of "srcdir": result.srcDir = ev.value
|
||||||
of "skipdirs":
|
of "skipdirs":
|
||||||
result.skipDirs.add(ev.value.split(','))
|
result.skipDirs.add(ev.value.multiSplit)
|
||||||
of "skipfiles":
|
of "skipfiles":
|
||||||
result.skipFiles.add(ev.value.split(','))
|
result.skipFiles.add(ev.value.multiSplit)
|
||||||
of "skipext":
|
of "skipext":
|
||||||
result.skipExt.add(ev.value.split(','))
|
result.skipExt.add(ev.value.multiSplit)
|
||||||
of "installdirs":
|
of "installdirs":
|
||||||
result.installDirs.add(ev.value.split(','))
|
result.installDirs.add(ev.value.multiSplit)
|
||||||
of "installfiles":
|
of "installfiles":
|
||||||
result.installFiles.add(ev.value.split(','))
|
result.installFiles.add(ev.value.multiSplit)
|
||||||
of "installext":
|
of "installext":
|
||||||
result.installExt.add(ev.value.split(','))
|
result.installExt.add(ev.value.multiSplit)
|
||||||
of "bin":
|
of "bin":
|
||||||
for i in ev.value.split(','):
|
for i in ev.value.multiSplit:
|
||||||
result.bin.add(i.addFileExt(ExeExt))
|
result.bin.add(i.addFileExt(ExeExt))
|
||||||
of "backend":
|
of "backend":
|
||||||
result.backend = ev.value.toLower()
|
result.backend = ev.value.toLower()
|
||||||
|
|
@ -127,7 +144,7 @@ proc readPackageInfo*(path: string): TPackageInfo =
|
||||||
of "deps", "dependencies":
|
of "deps", "dependencies":
|
||||||
case ev.key.normalize
|
case ev.key.normalize
|
||||||
of "requires":
|
of "requires":
|
||||||
for v in ev.value.split(','):
|
for v in ev.value.multiSplit:
|
||||||
result.requires.add(parseRequires(v.strip))
|
result.requires.add(parseRequires(v.strip))
|
||||||
else:
|
else:
|
||||||
quit("Invalid field: " & ev.key, QuitFailure)
|
quit("Invalid field: " & ev.key, QuitFailure)
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ packages is stored in a JSON file which is freely accessible in the
|
||||||
This JSON file provides babel with the required Git URL to clone the package
|
This JSON file provides babel with the required Git URL to clone the package
|
||||||
and install it. Installation and build instructions are contained inside a
|
and install it. Installation and build instructions are contained inside a
|
||||||
ini-style file with the ``.babel`` file extension. The babel file shares the
|
ini-style file with the ``.babel`` file extension. The babel file shares the
|
||||||
package's name.
|
package's name.
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue