Add metadata file to Options
This commit is contained in:
parent
564bc44d51
commit
d0807d575a
1 changed files with 19 additions and 4 deletions
|
|
@ -3,25 +3,40 @@ module Mima.MimaRun.Options
|
||||||
, parserInfo
|
, parserInfo
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Data.List
|
||||||
|
import Data.Maybe
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
|
|
||||||
data Options = Options
|
data Options = Options
|
||||||
{ inputFile :: FilePath
|
{ inputFile :: FilePath
|
||||||
|
, metadataFile :: FilePath
|
||||||
, steps :: Maybe Integer
|
, steps :: Maybe Integer
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
|
||||||
|
createOptions :: FilePath -> Maybe FilePath -> Maybe Integer -> Options
|
||||||
|
createOptions inFile metaFile = Options inFile resolvedMetadataFile
|
||||||
|
where
|
||||||
|
inputRenamedToMeta = removeExtension inFile ++ "mima-meta"
|
||||||
|
resolvedMetadataFile = fromMaybe inputRenamedToMeta metaFile
|
||||||
|
removeExtension = dropWhileEnd (/= '.')
|
||||||
|
|
||||||
parser :: Parser Options
|
parser :: Parser Options
|
||||||
parser = Options
|
parser = createOptions
|
||||||
<$> strArgument
|
<$> strArgument
|
||||||
( help "The .mima file to use"
|
( help "The .mima file to use"
|
||||||
<> metavar "INPUTFILE"
|
<> metavar "INPUTFILE"
|
||||||
)
|
)
|
||||||
|
<*> (optional . strOption)
|
||||||
|
( short 'm'
|
||||||
|
<> long "metadata"
|
||||||
|
<> help "The metadata file to use"
|
||||||
|
<> metavar "METAFILE"
|
||||||
|
)
|
||||||
<*> (optional . option auto)
|
<*> (optional . option auto)
|
||||||
( short 'n'
|
( short 'n'
|
||||||
<> long "steps"
|
<> long "steps"
|
||||||
<> help "Maximum number of steps to execute"
|
<> help "Maximum number of steps to execute"
|
||||||
<> metavar "STEPS"
|
<> metavar "STEPS"
|
||||||
)
|
)
|
||||||
|
|
||||||
parserInfo :: ParserInfo Options
|
parserInfo :: ParserInfo Options
|
||||||
parserInfo = info (parser <**> helper) (failureCode 1)
|
parserInfo = info (parser <**> helper) (failureCode 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue