clean exit codes for all the tools

This commit is contained in:
Araq 2011-08-01 07:56:10 +02:00
commit 00a4e19e8f
6 changed files with 30 additions and 14 deletions

View file

@ -26,6 +26,6 @@ proc main(dir, outfile: string) =
quit("Cannot open for writing: " & outfile) quit("Cannot open for writing: " & outfile)
if ParamCount() != 2: if ParamCount() != 2:
echo "Usage: cmerge directory outfile" quit "Usage: cmerge directory outfile"
else: else:
main(ParamStr(1), addFileExt(ParamStr(2), "c")) main(ParamStr(1), addFileExt(ParamStr(2), "c"))

View file

@ -237,8 +237,13 @@ proc walker(dir: string) =
else: nil else: nil
if existsFile(dir): processFile(dir) if existsFile(dir): processFile(dir)
proc writeHelp() = quit(Usage) proc writeHelp() =
proc writeVersion() = quit(Version) stdout.write(Usage)
quit(0)
proc writeVersion() =
stdout.write(Version & "\n")
quit(0)
proc checkOptions(subset: TOptions, a, b: string) = proc checkOptions(subset: TOptions, a, b: string) =
if subset <= options: if subset <= options:

View file

@ -1,7 +1,7 @@
# #
# #
# The Nimrod Installation Generator # The Nimrod Installation Generator
# (c) Copyright 2010 Andreas Rumpf # (c) Copyright 2011 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.
@ -142,8 +142,12 @@ proc parseCmdLine(c: var TConfigData) =
break break
of cmdLongOption, cmdShortOption: of cmdLongOption, cmdShortOption:
case normalize(key) case normalize(key)
of "help", "h": quit(Usage) of "help", "h":
of "version", "v": quit(Version) stdout.write(Usage)
quit(0)
of "version", "v":
stdout.write(Version & "\n")
quit(0)
of "o", "output": c.outdir = val of "o", "output": c.outdir = val
of "var": of "var":
var idx = val.find('=') var idx = val.find('=')

View file

@ -1,7 +1,7 @@
# #
# #
# Nimrod Website Generator # Nimrod Website Generator
# (c) Copyright 2010 Andreas Rumpf # (c) Copyright 2011 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.
@ -44,7 +44,7 @@ const
Version = "0.7" Version = "0.7"
Usage = "nimweb - Nimrod Website Generator Version " & version & """ Usage = "nimweb - Nimrod Website Generator Version " & version & """
(c) 2009 Andreas Rumpf (c) 2011 Andreas Rumpf
Usage: Usage:
nimweb [options] ini-file[.ini] [compile_options] nimweb [options] ini-file[.ini] [compile_options]
Options: Options:
@ -70,8 +70,12 @@ proc parseCmdLine(c: var TConfigData) =
break break
of cmdLongOption, cmdShortOption: of cmdLongOption, cmdShortOption:
case normalize(key) case normalize(key)
of "help", "h": quit(Usage) of "help", "h":
of "version", "v": quit(Version) stdout.write(Usage)
quit(0)
of "version", "v":
stdout.write(Version & "\n")
quit(0)
of "o", "output": c.outdir = val of "o", "output": c.outdir = val
of "var": of "var":
var idx = val.find('=') var idx = val.find('=')
@ -206,8 +210,11 @@ proc main(c: var TConfigData) =
var file = c.tabs[i].val var file = c.tabs[i].val
Exec(cmd % [c.nimrodArgs, file]) Exec(cmd % [c.nimrodArgs, file])
var temp = "web" / changeFileExt(file, "temp") var temp = "web" / changeFileExt(file, "temp")
var content = readFile(temp) var content: string
if isNil(content): quit("[Error] cannot open: " & temp) try:
content = readFile(temp)
except EIO:
quit("[Error] cannot open: " & temp)
var f: TFile var f: TFile
var outfile = "web/upload/$#.html" % file var outfile = "web/upload/$#.html" % file
if open(f, outfile, fmWrite): if open(f, outfile, fmWrite):

View file

@ -26,4 +26,4 @@ proc walker(dir: string) =
if paramCount() == 1: if paramCount() == 1:
walker(paramStr(1)) walker(paramStr(1))
else: else:
echo "Usage: trimcc c_compiler_directory" quit "Usage: trimcc c_compiler_directory"

View file

@ -40,7 +40,7 @@ Language Additions
- Added new ``is`` and ``of`` operators. - Added new ``is`` and ``of`` operators.
- The built-in type ``void`` can be used to denote the absense of any type. - The built-in type ``void`` can be used to denote the absense of any type.
This is only needed in generic contexts. This is useful in generic code.
- Return types may be of the type ``var T`` to return an l-value. - Return types may be of the type ``var T`` to return an l-value.