From b8f3867d54bc71423734953fd6939f73e7ec669b Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Tue, 25 Feb 2020 10:01:05 -0800 Subject: Start with a new stack project --- app/Main.hs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 app/Main.hs (limited to 'app/Main.hs') diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..de1c1ab --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,6 @@ +module Main where + +import Lib + +main :: IO () +main = someFunc -- cgit v1.2.3 From d9cd40f9d84e104207f8ef34c6d5a4f9d1b3af4b Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Tue, 25 Feb 2020 11:18:40 -0800 Subject: Add bare minimum of command line parsing --- app/Main.hs | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'app/Main.hs') diff --git a/app/Main.hs b/app/Main.hs index de1c1ab..9d9c5dc 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,6 +1,43 @@ module Main where -import Lib +import Options.Applicative + +newtype Arguments = Arguments { command' :: Command } + +data Command = Run | Test | Build main :: IO () -main = someFunc +main = do + args <- getArguments + run args + +run :: Arguments -> IO () +run args = case command' args of + Run -> putStrLn "Run" + Test -> putStrLn "Test" + Build -> putStrLn "Build" + +getArguments :: IO Arguments +getArguments = execParser + (info + (arguments <**> helper) + (fullDesc <> progDesc "Work with Fortran projects" <> header + "fpm - A Fortran package manager and build system" + ) + ) + +arguments :: Parser Arguments +arguments = subparser + ( command "run" (info runArguments (progDesc "Run the executable")) + <> command "test" (info testArguments (progDesc "Run the tests")) + <> command "build" (info buildArguments (progDesc "Build the executable")) + ) + +runArguments :: Parser Arguments +runArguments = pure $ Arguments Run + +testArguments :: Parser Arguments +testArguments = pure $ Arguments Test + +buildArguments :: Parser Arguments +buildArguments = pure $ Arguments Build -- cgit v1.2.3