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
|
import Mima.Vm.Storage
|
||||||
|
|
||||||
loadMetadataOrEmpty :: FilePath -> Run Metadata
|
loadMetadataOrEmpty :: FilePath -> Run Metadata
|
||||||
loadMetadataOrEmpty path = catch (loadMetadata path) (\error -> do
|
loadMetadataOrEmpty path = catch (loadMetadata path) $ \e -> do
|
||||||
liftIO $ putStrLn $ "Metafile could not be loaded. " ++ T.unpack error
|
liftIO $ putStrLn $ "Metafile could not be loaded. " ++ T.unpack e
|
||||||
pure mempty)
|
pure mempty
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = runOrExit 2 $ do
|
main = runOrExit 2 $ do
|
||||||
|
|
@ -38,5 +38,6 @@ main = runOrExit 2 $ do
|
||||||
Nothing -> putStrLn "Ran out of steps"
|
Nothing -> putStrLn "Ran out of steps"
|
||||||
Just abortReason -> T.putStrLn $ toText abortReason
|
Just abortReason -> T.putStrLn $ toText abortReason
|
||||||
pure finalState
|
pure finalState
|
||||||
|
|
||||||
liftIO $ putStrLn ""
|
liftIO $ putStrLn ""
|
||||||
liftIO $ print finalState
|
liftIO $ print finalState
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ module Mima.MimaRun.Options
|
||||||
, parserInfo
|
, parserInfo
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.List
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
|
import System.FilePath
|
||||||
|
|
||||||
data Options = Options
|
data Options = Options
|
||||||
{ inputFile :: FilePath
|
{ inputFile :: FilePath
|
||||||
|
|
@ -14,11 +14,9 @@ data Options = Options
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
|
||||||
createOptions :: FilePath -> Maybe FilePath -> Maybe Integer -> Options
|
createOptions :: FilePath -> Maybe FilePath -> Maybe Integer -> Options
|
||||||
createOptions inFile metaFile = Options inFile resolvedMetadataFile
|
createOptions inFile metaFile = Options inFile resolvedMetaFile
|
||||||
where
|
where
|
||||||
inputRenamedToMeta = removeExtension inFile ++ "mima-meta"
|
resolvedMetaFile = fromMaybe (replaceExtension inFile "mima-meta") metaFile
|
||||||
resolvedMetadataFile = fromMaybe inputRenamedToMeta metaFile
|
|
||||||
removeExtension = dropWhileEnd (/= '.')
|
|
||||||
|
|
||||||
parser :: Parser Options
|
parser :: Parser Options
|
||||||
parser = createOptions
|
parser = createOptions
|
||||||
|
|
@ -38,5 +36,6 @@ parser = createOptions
|
||||||
<> 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)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ dependencies:
|
||||||
- binary
|
- binary
|
||||||
- bytestring
|
- bytestring
|
||||||
- containers
|
- containers
|
||||||
|
- filepath
|
||||||
- optparse-applicative
|
- optparse-applicative
|
||||||
- text
|
- text
|
||||||
- transformers
|
- transformers
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue