Use package for modifying paths
This commit is contained in:
parent
fdc755ecb0
commit
7b7a363693
3 changed files with 10 additions and 9 deletions
|
|
@ -14,9 +14,9 @@ import Mima.Vm.State
|
|||
import Mima.Vm.Storage
|
||||
|
||||
loadMetadataOrEmpty :: FilePath -> Run Metadata
|
||||
loadMetadataOrEmpty path = catch (loadMetadata path) (\error -> do
|
||||
liftIO $ putStrLn $ "Metafile could not be loaded. " ++ T.unpack error
|
||||
pure mempty)
|
||||
loadMetadataOrEmpty path = catch (loadMetadata path) $ \e -> do
|
||||
liftIO $ putStrLn $ "Metafile could not be loaded. " ++ T.unpack e
|
||||
pure mempty
|
||||
|
||||
main :: IO ()
|
||||
main = runOrExit 2 $ do
|
||||
|
|
@ -38,5 +38,6 @@ main = runOrExit 2 $ do
|
|||
Nothing -> putStrLn "Ran out of steps"
|
||||
Just abortReason -> T.putStrLn $ toText abortReason
|
||||
pure finalState
|
||||
|
||||
liftIO $ putStrLn ""
|
||||
liftIO $ print finalState
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ module Mima.MimaRun.Options
|
|||
, parserInfo
|
||||
) where
|
||||
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
import Options.Applicative
|
||||
import System.FilePath
|
||||
|
||||
data Options = Options
|
||||
{ inputFile :: FilePath
|
||||
|
|
@ -14,11 +14,9 @@ data Options = Options
|
|||
} deriving (Show)
|
||||
|
||||
createOptions :: FilePath -> Maybe FilePath -> Maybe Integer -> Options
|
||||
createOptions inFile metaFile = Options inFile resolvedMetadataFile
|
||||
createOptions inFile metaFile = Options inFile resolvedMetaFile
|
||||
where
|
||||
inputRenamedToMeta = removeExtension inFile ++ "mima-meta"
|
||||
resolvedMetadataFile = fromMaybe inputRenamedToMeta metaFile
|
||||
removeExtension = dropWhileEnd (/= '.')
|
||||
resolvedMetaFile = fromMaybe (replaceExtension inFile "mima-meta") metaFile
|
||||
|
||||
parser :: Parser Options
|
||||
parser = createOptions
|
||||
|
|
@ -27,7 +25,7 @@ parser = createOptions
|
|||
<> metavar "INPUTFILE"
|
||||
)
|
||||
<*> (optional . strOption)
|
||||
( short 'm'
|
||||
( short 'm'
|
||||
<> long "metadata"
|
||||
<> help "The metadata file to use"
|
||||
<> metavar "METAFILE"
|
||||
|
|
@ -38,5 +36,6 @@ parser = createOptions
|
|||
<> help "Maximum number of steps to execute"
|
||||
<> metavar "STEPS"
|
||||
)
|
||||
|
||||
parserInfo :: ParserInfo Options
|
||||
parserInfo = info (parser <**> helper) (failureCode 1)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ dependencies:
|
|||
- binary
|
||||
- bytestring
|
||||
- containers
|
||||
- filepath
|
||||
- optparse-applicative
|
||||
- text
|
||||
- transformers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue