Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • geode/ghc-geode
1 result
Show changes
Commits on Source (2)
......@@ -5,13 +5,14 @@ module GEODE.Options
, Output(..)
, input
, ioConfig
, output ) where
, output
, xmlOutput ) where
import Control.Applicative ((<|>))
import Data.List.NonEmpty (NonEmpty(..))
import Options.Applicative
( Parser, argument, flag', help, long, metavar, short, str, strOption, value )
import Options.Applicative.Types (oneM, manyM, fromM)
import Options.Applicative.NonEmpty (some1)
import Text.Printf (printf)
data Input = StdIn | File FilePath
......@@ -21,24 +22,28 @@ input stdinSemantics =
argument
(File <$> str)
( value StdIn
<> metavar "INPUT_FILE"
<> help (printf "path of the file to process (%s)" stdinSemantics) )
<> metavar "INPUT_FILE"
<> help (printf "path of the file to process (%s)" stdinSemantics) )
data Output = Metadata | TextRoot FilePath | XMLRoot FilePath
xmlOutput :: Parser FilePath
xmlOutput =
strOption
( long "xml-root" <> metavar "DIRECTORY" <> short 'x'
<> help "Root path where to output XML files" )
output :: Parser Output
output =
flag' Metadata ( long "metadata"
<> short 'm'
<> help "Print metadata for splitted files on stdout" )
<> short 'm'
<> help "Print metadata for splitted files on stdout" )
<|> (TextRoot <$> strOption
( long "text-root"
<> short 't'
<> help "Root path where to output text files" ))
<|> (XMLRoot <$> strOption
( long "xml-root"
<> short 'x'
<> help "Root path where to output XML files" ))
<> metavar "DIRECTORY"
<> short 't'
<> help "Root path where to output text files" ))
<|> (XMLRoot <$> xmlOutput)
data IOConfig = IOConfig
{ from :: Input
......@@ -47,8 +52,4 @@ data IOConfig = IOConfig
ioConfig :: String -> Parser IOConfig
ioConfig stdinSemantics = IOConfig
<$> input stdinSemantics
<*> some output
where
-- trick needed to avoid duplicated options in help message (occurring when
-- working directly at the Applicative level)
some p = fromM ((:|) <$> oneM p <*> manyM p)
<*> some1 output