mdoc-0.1.0.0: test/Mdoc/Test/Fixtures.hs
{-# OPTIONS_GHC -Wno-ambiguous-fields #-}
module Mdoc.Test.Fixtures
( grepBase
, grepOpt
, grepEnv
, confBase
, confConf
, exampleBase1
, exampleBase5
, exampleOptEnvConf
) where
import Mdoc.Prelude
import Env qualified
import Mdoc.Gen.CrossRef
import Mdoc.Gen.Man1
import Mdoc.Gen.Man5
import Mdoc.Gen.Name
import OptEnvConf qualified
import Options.Applicative qualified as OA
grepBase :: Man1
grepBase =
(baseMan1 "" "")
{ name =
Name
{ primary = "grep"
, secondaries = ["egrep", "fgrep", "rgrep"]
, description = "file pattern searcher"
}
, seeAlso =
[ CrossRef "ed" 1
, CrossRef "ex" 1
, CrossRef "sed" 1
, CrossRef "zgrep" 1
, CrossRef "re_format" 7
]
}
{- FOURMOLU_DISABLE -}
grepOpt :: OA.Parser ()
grepOpt = void $ (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
<$> OA.optional (OA.option (OA.auto @Int) (mconcat [OA.short 'A', OA.metavar "num", OA.help "Print num lines of trailing context after each match. See also the -B and -C options."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'a', OA.help "Treat all files as ASCII text. Normally grep will simply print “Binary file ... matches” if files contain binary characters. Use of this option forces grep to output lines matching the specified pattern."]))
<*> OA.optional (OA.option (OA.auto @Int) (mconcat [OA.short 'B', OA.metavar "num", OA.help "Print num lines of leading context before each match. See also the -A and -C options."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'b', OA.help "Each output line is preceded by its position (in bytes) in the file. If option -o is also specified, the position of the matched pattern is displayed."]))
<*> OA.optional (OA.option (OA.auto @Int) (mconcat [OA.short 'C', OA.long "context", OA.metavar "num", OA.help "Print num lines of leading and trailing context surrounding each match. The default is 2 and is equivalent to -A 2 -B 2. Note: no whitespace may be given between the option and its argument."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'c', OA.help "Only a count of selected lines is written to standard output."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'E', OA.help "Interpret pattern as an extended regular expression (i.e. force grep to behave as egrep)."]))
<*> OA.optional (OA.option (OA.str @String) (mconcat [OA.short 'e', OA.metavar "pattern", OA.help "Specify a pattern used during the search of the input: an input line is selected if it matches any of the specified patterns. This option is most useful when multiple -e options are used to specify multiple patterns, or when a pattern begins with a dash (‘-’)."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'F', OA.help "Interpret pattern as a set of fixed strings (i.e. force grep to behave as fgrep)."]))
<*> OA.optional (OA.option (OA.str @String) (mconcat [OA.short 'f', OA.metavar "file", OA.help "Read one or more newline separated patterns from file. Empty pattern lines match every input line. Newlines are not considered part of a pattern. If file is empty, nothing is matched."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'G', OA.help "Interpret pattern as a basic regular expression (i.e. force grep to behave as traditional grep)."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'H', OA.help "Always print filename headers (i.e. filenames) with output lines."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'h', OA.help "Never print filename headers (i.e. filenames) with output lines."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'I', OA.help "Ignore binary files."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'i', OA.help "Perform case insensitive matching. By default, grep is case sensitive."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'L', OA.help "Only the names of files not containing selected lines are written to standard output. Pathnames are listed once per file searched. If the standard input is searched, the string “(standard input)” is written."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'l', OA.help "Only the names of files containing selected lines are written to standard output. grep will only search a file until a match has been found, making searches potentially less expensive. Pathnames are listed once per file searched. If the standard input is searched, the string “(standard input)” is written."]))
<*> OA.optional (OA.option (OA.auto @Int) (mconcat [OA.short 'm', OA.metavar "num", OA.help "Stop after finding at least one match on num different lines."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'n', OA.help "Each output line is preceded by its relative line number in the file, starting at line 1. The line number counter is reset for each file processed. This option is ignored if -c, -L, -l, or -q is specified."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'o', OA.help "Print each match, but only the match, not the entire line."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'q', OA.help "Quiet mode: suppress normal output. grep will only search a file until a match has been found, making searches potentially less expensive."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'R', OA.help "Recursively search subdirectories listed. If no file is given, grep searches the current working directory."]))
<*> OA.optional (OA.switch (mconcat [OA.short 's', OA.help "Silent mode. Nonexistent and unreadable files are ignored (i.e. their error messages are suppressed)."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'U', OA.help "Search binary files, but do not attempt to print them."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'V', OA.help "Display version information. All other options are ignored."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'v', OA.help "Selected lines are those not matching any of the specified patterns."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'w', OA.help "The expression is searched for as a word (as if surrounded by ‘[[:<:]]’ and ‘[[:>:]]’; see re_format(7))."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'x', OA.help "Only input lines selected against an entire fixed string or regular expression are considered to be matching lines."]))
<*> OA.optional (OA.switch (mconcat [OA.short 'Z', OA.help "Force grep to behave as zgrep."]))
<*> OA.optional (OA.option (OA.str @String) (mconcat [OA.long "binary-files", OA.metavar "value", OA.help "Controls searching and printing of binary files. Options are binary, the default: search binary files but do not print them; without-match: do not search binary files; and text: treat all files as text."]))
<*> OA.optional (OA.option (OA.str @String) (mconcat [OA.long "label", OA.metavar "name", OA.help "Print name instead of the filename before lines."]))
<*> OA.optional (OA.switch (mconcat [OA.long "line-buffered", OA.help "Force output to be line buffered. By default, output is line buffered when standard output is a terminal and block buffered otherwise."]))
<*> OA.optional (OA.switch (mconcat [OA.long "null", OA.help "Output a zero byte instead of the character that normally follows a file name. This option makes the output unambiguous, even in the presence of file names containing unusual characters like newlines. This is similar to the -print0 primary in find(1)."]))
<*> OA.optional (OA.argument (OA.str @String) (mconcat [OA.metavar "pattern"]))
<*> OA.many (OA.argument (OA.str @String) (mconcat [OA.metavar "file"]))
grepEnv :: Env.Parser Env.Error ()
grepEnv = void $ (,,)
<$> (Env.var @Env.Error @Text) Env.str "GREP_COLOR" (Env.help "This variable specifies the color used to highlight matched (non-empty) text.")
<*> (Env.var @Env.Error @Text) Env.str "GREP_OPTIONS" (Env.help "This variable specifies default options to be placed in front of any explicit options. It may cause problems with portable scripts.")
<*> (Env.var @Env.Error @Text) Env.str "TERM" (Env.help "This variable specifies the type name of the terminal, console or display-device type to be used. See term(7).")
{- FOURMOLU_ENABLE -}
confBase :: Man5
confBase =
(baseMan5 "" "" "")
{ name =
Name
{ primary = "crontab"
, secondaries = []
, description = "tables for driving cron"
}
, files = fromString . ("/etc/cron." <>) <$> ("daily" :| ["hourly", "weekly"])
}
{- FOURMOLU_DISABLE -}
confConf :: OptEnvConf.Parser ()
confConf = void $ (,)
<$> OptEnvConf.setting [OptEnvConf.conf @String "foo", OptEnvConf.help "Foo's the fooing of fooers"]
<*> OptEnvConf.subConfig "bar" ((,)
<$> OptEnvConf.setting [OptEnvConf.conf @Bool "baz", OptEnvConf.help "Bar's baz of bazzle"]
<*> OptEnvConf.setting [OptEnvConf.conf @[Int] "bat", OptEnvConf.help "Bar's bat is better than that"])
{- FOURMOLU_ENABLE -}
exampleBase1 :: Man1
exampleBase1 = baseMan1 "example" "opt-env-conf example"
exampleBase5 :: Man5
exampleBase5 = baseMan5 "examplerc" "opt-env-conf example config" ".examplerc.yaml"
{- FOURMOLU_DISABLE -}
exampleOptEnvConf :: OptEnvConf.Parser (Bool, Bool, Text, Text, [Text])
exampleOptEnvConf = (,,,,)
<$> OptEnvConf.setting [OptEnvConf.env "DEBUG", OptEnvConf.conf "debug", OptEnvConf.switch True, OptEnvConf.long "debug", OptEnvConf.help "Enable debug", OptEnvConf.value False]
<*> OptEnvConf.setting [OptEnvConf.conf "verbose", OptEnvConf.switch True, OptEnvConf.short 'v', OptEnvConf.long "verbose", OptEnvConf.value False]
<*> OptEnvConf.setting [OptEnvConf.env "INPUT", OptEnvConf.option, OptEnvConf.reader OptEnvConf.str, OptEnvConf.short 'i', OptEnvConf.metavar "INPUT"]
<*> OptEnvConf.setting [OptEnvConf.conf "file", OptEnvConf.argument, OptEnvConf.reader OptEnvConf.str, OptEnvConf.metavar "FILE"]
<*> OptEnvConf.many (OptEnvConf.setting [OptEnvConf.argument, OptEnvConf.reader OptEnvConf.str, OptEnvConf.metavar "FILE"])
{- FOURMOLU_ENABLE -}