Skip to content

Commit

Permalink
Add --dump-default-config option
Browse files Browse the repository at this point in the history
  • Loading branch information
fmthoma committed Dec 4, 2016
1 parent 8c37b44 commit 8ffbdf5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ main = do
args <- getArgs
when ("-V" `elem` args || "--version" `elem` args) (printVersion >> exitSuccess)
when ("--help" `elem` args) (printHelp >> exitSuccess)
when ("--dump-default-config" `elem` args) (printDefaultConfig >> exitSuccess)

hSetBuffering stdin LineBuffering
hSetBuffering stdout LineBuffering
Expand Down Expand Up @@ -82,6 +83,8 @@ main = do
runEffect (grepVersion >-> P.take 1 >-> P.map (" " <>) >-> stdoutText)
printHelp = putStrLn helpText
where helpText = $(fmap (LitE . StringL) (runIO (readFile "help.txt")))
printDefaultConfig = putStrLn defaultConfigFile
where defaultConfigFile = $(fmap (LitE . StringL) (runIO (readFile "config.yaml.example")))


type MainWidget = HSplitWidget Results Pager
Expand Down
11 changes: 11 additions & 0 deletions help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,15 @@ Usage:
as a pager for `grep -nH` output:
grep -nH [GREP_OPTION...] PATTERN [FILE] | vgrep


Additional options:
--help, -V Prints this help.

--version Prints version info and exits

--dump-default-config
Prints the default config file to stdout and exits.
(Usage: `vgrep --dump-default-config > ~/.vgrep/config.yaml`)


For documentation on grep options an patterns see `grep --help`.

0 comments on commit 8ffbdf5

Please sign in to comment.