diff options
author | Brad Richardson <brichardson@structint.com> | 2020-02-25 11:18:40 -0800 |
---|---|---|
committer | Brad Richardson <brichardson@structint.com> | 2020-02-25 11:44:41 -0800 |
commit | d9cd40f9d84e104207f8ef34c6d5a4f9d1b3af4b (patch) | |
tree | 7b13ccc55588d467708c20f14b114cc56bb93b0b | |
parent | 2d6a18354b5c848bd655bfc2a642b93699eb2b09 (diff) | |
download | fpm-d9cd40f9d84e104207f8ef34c6d5a4f9d1b3af4b.tar.gz fpm-d9cd40f9d84e104207f8ef34c6d5a4f9d1b3af4b.zip |
Add bare minimum of command line parsing
-rw-r--r-- | app/Main.hs | 41 | ||||
-rw-r--r-- | package.yaml | 1 | ||||
-rw-r--r-- | stack.yaml | 2 | ||||
-rw-r--r-- | stack.yaml.lock | 8 |
4 files changed, 45 insertions, 7 deletions
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 diff --git a/package.yaml b/package.yaml index ab3a1d0..2cf73a8 100644 --- a/package.yaml +++ b/package.yaml @@ -21,6 +21,7 @@ description: Please see the README on GitHub at <https://github.com/gith dependencies: - base >= 4.7 && < 5 +- optparse-applicative library: source-dirs: src @@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-15.1 +resolver: lts-12.26 # User packages to be built. # Various formats can be used as shown in the example below. diff --git a/stack.yaml.lock b/stack.yaml.lock index 7e51098..6bee1e8 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -6,7 +6,7 @@ packages: [] snapshots: - completed: - size: 489011 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/15/1.yaml - sha256: d4ecc42b7125d68e4c3c036a08046ad0cd02ae0d9efbe3af2223a00ff8cc16f3 - original: lts-15.1 + size: 509471 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/12/26.yaml + sha256: 95f014df58d0679b1c4a2b7bf2b652b61da8d30de5f571abb0d59015ef678646 + original: lts-12.26 |