Validate nimgrep filter options not empty (#20562)
This commit is contained in:
parent
be18f4e513
commit
b793ca7394
1 changed files with 19 additions and 13 deletions
|
|
@ -11,7 +11,7 @@ import
|
||||||
os, strutils, parseopt, pegs, re, terminal, osproc, tables, algorithm, times
|
os, strutils, parseopt, pegs, re, terminal, osproc, tables, algorithm, times
|
||||||
|
|
||||||
const
|
const
|
||||||
Version = "1.6.0"
|
Version = "2.0.0"
|
||||||
Usage = "nimgrep - Nim Grep Searching and Replacement Utility Version " &
|
Usage = "nimgrep - Nim Grep Searching and Replacement Utility Version " &
|
||||||
Version & """
|
Version & """
|
||||||
|
|
||||||
|
|
@ -1258,6 +1258,11 @@ for kind, key, val in getopt():
|
||||||
else:
|
else:
|
||||||
paths.add(key)
|
paths.add(key)
|
||||||
of cmdLongOption, cmdShortOption:
|
of cmdLongOption, cmdShortOption:
|
||||||
|
proc addNotEmpty(s: var seq[string], name: string) =
|
||||||
|
if name == "":
|
||||||
|
reportError("empty string given for option --" & key &
|
||||||
|
" (did you forget `:`?)")
|
||||||
|
s.add name
|
||||||
case normalize(key)
|
case normalize(key)
|
||||||
of "find", "f": incl(options, optFind)
|
of "find", "f": incl(options, optFind)
|
||||||
of "replace", "!": incl(options, optReplace)
|
of "replace", "!": incl(options, optReplace)
|
||||||
|
|
@ -1288,30 +1293,31 @@ for kind, key, val in getopt():
|
||||||
"noext", "no-ext": # 2 deprecated options
|
"noext", "no-ext": # 2 deprecated options
|
||||||
walkOpt.notExtensions.add val.split('|')
|
walkOpt.notExtensions.add val.split('|')
|
||||||
of "dirname", "di":
|
of "dirname", "di":
|
||||||
walkOpt.dirname.add val
|
walkOpt.dirname.addNotEmpty val
|
||||||
of "ndirname", "notdirname", "ndi", "notdi",
|
of "ndirname", "notdirname", "ndi", "notdi",
|
||||||
"excludedir", "ed": # 2 deprecated options
|
"excludedir", "exclude-dir", "ed": # 3 deprecated options
|
||||||
walkOpt.notDirname.add val
|
walkOpt.notDirname.addNotEmpty val
|
||||||
of "dirpath", "dirp",
|
of "dirpath", "dirp",
|
||||||
"includedir", "id": # 2 deprecated options
|
"includedir", "include-dir", "id": # 3 deprecated options
|
||||||
walkOpt.dirPath.add val
|
walkOpt.dirPath.addNotEmpty val
|
||||||
of "ndirpath", "notdirpath", "ndirp", "notdirp":
|
of "ndirpath", "notdirpath", "ndirp", "notdirp":
|
||||||
walkOpt.notDirPath.add val
|
walkOpt.notDirPath.addNotEmpty val
|
||||||
of "filename", "fi",
|
of "filename", "fi",
|
||||||
"includefile", "include-file", "if": # 3 deprecated options
|
"includefile", "include-file", "if": # 3 deprecated options
|
||||||
walkOpt.filename.add val
|
walkOpt.filename.addNotEmpty val
|
||||||
of "nfilename", "nfi", "notfilename", "notfi",
|
of "nfilename", "nfi", "notfilename", "notfi",
|
||||||
"excludefile", "exclude-file", "ef": # 3 deprecated options
|
"excludefile", "exclude-file", "ef": # 3 deprecated options
|
||||||
walkOpt.notFilename.add val
|
walkOpt.notFilename.addNotEmpty val
|
||||||
of "infile", "inf",
|
of "infile", "inf",
|
||||||
"matchfile", "match", "mf": # 3 deprecated options
|
"matchfile", "match", "mf": # 3 deprecated options
|
||||||
searchOpt.inFile.add val
|
searchOpt.inFile.addNotEmpty val
|
||||||
of "ninfile", "notinfile", "ninf", "notinf",
|
of "ninfile", "notinfile", "ninf", "notinf",
|
||||||
"nomatchfile", "nomatch", "nf": # 3 options are deprecated
|
"nomatchfile", "nomatch", "nf": # 3 options are deprecated
|
||||||
searchOpt.notInFile.add val
|
searchOpt.notInFile.addNotEmpty val
|
||||||
of "incontext", "inc": searchOpt.inContext.add val
|
of "incontext", "inc":
|
||||||
|
searchOpt.inContext.addNotEmpty val
|
||||||
of "nincontext", "notincontext", "ninc", "notinc":
|
of "nincontext", "notincontext", "ninc", "notinc":
|
||||||
searchOpt.notInContext.add val
|
searchOpt.notInContext.addNotEmpty val
|
||||||
of "bin":
|
of "bin":
|
||||||
case val
|
case val
|
||||||
of "on": searchOpt.checkBin = biOn
|
of "on": searchOpt.checkBin = biOn
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue