parent
f804245087
commit
5a65243e14
1 changed files with 12 additions and 4 deletions
|
|
@ -33,7 +33,8 @@ Options:
|
||||||
--ignoreCase, -i be case insensitive
|
--ignoreCase, -i be case insensitive
|
||||||
--ignoreStyle, -y be style insensitive
|
--ignoreStyle, -y be style insensitive
|
||||||
--ext:EX1|EX2|... only search the files with the given extension(s)
|
--ext:EX1|EX2|... only search the files with the given extension(s)
|
||||||
--nocolor output will be given without any colours.
|
--nocolor output will be given without any colours
|
||||||
|
--color[:always] force color even if output is redirected
|
||||||
--group group matches by file
|
--group group matches by file
|
||||||
--verbose be verbose: list every processed file
|
--verbose be verbose: list every processed file
|
||||||
--filenames find the pattern in the filenames, not in the contents
|
--filenames find the pattern in the filenames, not in the contents
|
||||||
|
|
@ -270,6 +271,10 @@ proc checkOptions(subset: TOptions, a, b: string) =
|
||||||
if subset <= options:
|
if subset <= options:
|
||||||
quit("cannot specify both '$#' and '$#'" % [a, b])
|
quit("cannot specify both '$#' and '$#'" % [a, b])
|
||||||
|
|
||||||
|
when defined(posix):
|
||||||
|
useWriteStyled = terminal.isatty(stdout)
|
||||||
|
# that should be before option processing to allow override of useWriteStyled
|
||||||
|
|
||||||
oneline = true
|
oneline = true
|
||||||
for kind, key, val in getopt():
|
for kind, key, val in getopt():
|
||||||
case kind
|
case kind
|
||||||
|
|
@ -304,6 +309,12 @@ for kind, key, val in getopt():
|
||||||
of "ignorestyle", "y": incl(options, optIgnoreStyle)
|
of "ignorestyle", "y": incl(options, optIgnoreStyle)
|
||||||
of "ext": extensions.add val.split('|')
|
of "ext": extensions.add val.split('|')
|
||||||
of "nocolor": useWriteStyled = false
|
of "nocolor": useWriteStyled = false
|
||||||
|
of "color":
|
||||||
|
case val
|
||||||
|
of "auto": discard
|
||||||
|
of "never", "false": useWriteStyled = false
|
||||||
|
of "", "always", "true": useWriteStyled = true
|
||||||
|
else: writeHelp()
|
||||||
of "oneline": oneline = true
|
of "oneline": oneline = true
|
||||||
of "group": oneline = false
|
of "group": oneline = false
|
||||||
of "verbose": incl(options, optVerbose)
|
of "verbose": incl(options, optVerbose)
|
||||||
|
|
@ -313,9 +324,6 @@ for kind, key, val in getopt():
|
||||||
else: writeHelp()
|
else: writeHelp()
|
||||||
of cmdEnd: assert(false) # cannot happen
|
of cmdEnd: assert(false) # cannot happen
|
||||||
|
|
||||||
when defined(posix):
|
|
||||||
useWriteStyled = terminal.isatty(stdout)
|
|
||||||
|
|
||||||
checkOptions({optFind, optReplace}, "find", "replace")
|
checkOptions({optFind, optReplace}, "find", "replace")
|
||||||
checkOptions({optPeg, optRegex}, "peg", "re")
|
checkOptions({optPeg, optRegex}, "peg", "re")
|
||||||
checkOptions({optIgnoreCase, optIgnoreStyle}, "ignore_case", "ignore_style")
|
checkOptions({optIgnoreCase, optIgnoreStyle}, "ignore_case", "ignore_style")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue