simplify nimscript.nim

This commit is contained in:
Araq
2015-08-21 01:34:46 +02:00
parent 9659540b18
commit a2bb7d4c71
3 changed files with 10 additions and 25 deletions

View File

@@ -355,7 +355,7 @@ proc mainCommand* =
gGlobalOptions.incl(optCaasEnabled)
msgs.gErrorMax = high(int) # do not stop after first error
serve(mainCommand)
of "nop": discard
of "nop", "help": discard
else:
rawMessage(errInvalidCommandX, command)

View File

@@ -144,28 +144,13 @@ template task*(name: untyped; description: string; body: untyped): untyped =
proc `name Task`() = body
let cmd = getCommand()
if cmd.len == 0 or cmd ==? "help" or cmd == "nop":
setCommand "nop"
if cmd.len == 0 or cmd ==? "help":
setCommand "help"
writeTask(astToStr(name), description)
elif cmd ==? astToStr(name):
setCommand "nop"
`name Task`()
type
VersionReq* = distinct string ## Describes a version requirement.
template v*(name: string{lit}): VersionReq = VersionReq(name)
template special*(name: string): VersionReq = VersionReq(name)
template `<`*(v: VersionReq): VersionReq = VersionReq("<" & string(v))
template `<=`*(v: VersionReq): VersionReq = VersionReq("<=" & string(v))
template `>`*(v: VersionReq): VersionReq = VersionReq(">" & string(v))
template `>=`*(v: VersionReq): VersionReq = VersionReq(">=" & string(v))
template `&`*(a, b: VersionReq): VersionReq =
VersionReq(string(a) & " & " & string(b))
const
anyVersion* = VersionReq("*")
var
packageName* = ""
version*, author*, description*, license*, srcdir*,
@@ -173,7 +158,7 @@ var
skipDirs*, skipFiles*, skipExt*, installDirs*, installFiles*,
installExt*, bin*: seq[string]
requiresData*: seq[(string, VersionReq)]
requiresData*: seq[string]
proc requires*(name: string; v: VersionReq) =
requiresData.add((name, v))
proc requires*(deps: varargs[string]) =
for d in deps: requiresData.add(d)

View File

@@ -15,10 +15,6 @@ version 0.11.4
- add "all threads are blocked" detection to 'spawn'
- Deprecate ``immediate`` for templates and macros
- make 'nil' work for 'add':
- resizeString
- incrSeq
- addChar
version 1.0
@@ -36,6 +32,10 @@ version 1.0
- split docgen into separate tool
- special rule for ``[]=``, items, pairs
- BUG: echo with template `$`*(info: TLineInfo): expr = toFileLineCol(info)
- make 'nil' work for 'add':
- resizeString
- incrSeq
- addChar
Concurrency