Add -h, --version, and --help options.

This commit is contained in:
Jonathan Bernard 2017-08-23 15:17:18 -05:00
parent b0e6e4d66f
commit 3a745ac98f
2 changed files with 9 additions and 4 deletions

View File

@ -35,7 +35,7 @@ when isMainModule:
var outFile: File var outFile: File
try: try:
let VERSION = "0.1.0" let VERSION = "0.2.0"
let usage = """ let usage = """
Usage: Usage:
log_happy [options] log_happy [options]
@ -44,7 +44,8 @@ Usage:
Options: Options:
-v Print version information and exit. -h --help Print this usage information and exit.
-v --version Print version information and exit.
-e<label>;<pattern> Add something to expect to see in the log stream. -e<label>;<pattern> Add something to expect to see in the log stream.
-E<label>;<patterh> Add something to expect not to see in the log stream. -E<label>;<patterh> Add something to expect not to see in the log stream.
-d<def-file> Read expectations from a JSON definitions file. -d<def-file> Read expectations from a JSON definitions file.
@ -136,10 +137,14 @@ Expectations JSON definitions follow this format:
expected: m[0] == "e", expected: m[0] == "e",
found: false)) found: false))
elif arg == "-v": elif arg == "-v" or arg == "--version":
stdout.writeLine "log_happy v" & VERSION stdout.writeLine "log_happy v" & VERSION
quit(QuitSuccess) quit(QuitSuccess)
elif arg == "-h" or arg == "--help":
stdout.writeLine usage
quit(QuitSuccess)
elif arg == "-f": follow = true elif arg == "-f": follow = true
elif arg == "--": cmd = "" elif arg == "--": cmd = ""
else: exitErr "unrecognized argument: " & arg else: exitErr "unrecognized argument: " & arg

View File

@ -1,6 +1,6 @@
# Package # Package
version = "0.1.0" version = "0.2.0"
author = "Jonathan Bernard" author = "Jonathan Bernard"
description = "Scan logs for regex-defined events and report on what was found." description = "Scan logs for regex-defined events and report on what was found."
license = "MIT" license = "MIT"