clean exit codes for all the tools

This commit is contained in:
Araq
2011-08-01 07:56:10 +02:00
parent dd99fe61c0
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)
if ParamCount() != 2:
echo "Usage: cmerge directory outfile"
quit "Usage: cmerge directory outfile"
else:
main(ParamStr(1), addFileExt(ParamStr(2), "c"))

View File

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

View File

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

View File

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

View File

@@ -26,4 +26,4 @@ proc walker(dir: string) =
if paramCount() == 1:
walker(paramStr(1))
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.
- 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.