aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
l---------perfume1
-rw-r--r--perfume.cabal1
-rw-r--r--src/CommandLineOptions.hs33
3 files changed, 34 insertions, 1 deletions
diff --git a/perfume b/perfume
deleted file mode 120000
index f5b7185..0000000
--- a/perfume
+++ /dev/null
@@ -1 +0,0 @@
-./dist/build/perfume/perfume \ No newline at end of file
diff --git a/perfume.cabal b/perfume.cabal
index f096a35..e508c42 100644
--- a/perfume.cabal
+++ b/perfume.cabal
@@ -18,3 +18,4 @@ executable perfume
, aeson == 0.9.0.1
, utf8-string == 1.0.1.1
, directory == 1.2.3.1
+ , optparse-applicative == 0.11.0.2
diff --git a/src/CommandLineOptions.hs b/src/CommandLineOptions.hs
new file mode 100644
index 0000000..2a1f585
--- /dev/null
+++ b/src/CommandLineOptions.hs
@@ -0,0 +1,33 @@
+module CommandLineOptions
+ ( Sample(..)
+ , getOptions
+ ) where
+
+import Options.Applicative
+
+data Sample = Sample
+ { hello :: String
+ , quiet :: Bool
+ }
+
+getOptions :: IO Sample
+getOptions =
+ execParser $ info
+ (helper <*> sample)
+ ( fullDesc
+ <> progDesc "Print a greeting for TARGET"
+ <> header "hello - a test for optparse-applicative"
+ )
+
+sample :: Parser Sample
+sample =
+ Sample
+ <$> strOption
+ ( long "name"
+ <> metavar "TARGET"
+ <> help "Target for the greeting"
+ )
+ <*> switch
+ ( long "quiet"
+ <> help "Whether to be quiet"
+ )