Skip to content

Commit

Permalink
update optparse example with optional field example
Browse files Browse the repository at this point in the history
  • Loading branch information
austin-artificial committed Feb 4, 2025
1 parent bdaacd6 commit 484b2ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/32-optparse.hell
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-- Includes example of Semigroup.
data Opts = Opts {
quiet :: Bool,
filePath :: Text
filePath :: Maybe Text
}
options =
(\quiet path -> Main.Opts { quiet = quiet, filePath = path })
<$> Options.switch (Flag.long "quiet" <> Flag.help "Be quiet?")
<*> Options.strOption (Option.long "path" <> Option.help "The filepath to export")
<*> (Alternative.optional $ Options.strOption (Option.long "path" <> Option.help "The filepath to export"))
main = do
opts <- Options.execParser (Options.info (Main.options <**> Options.helper) Options.fullDesc)
Text.putStrLn $ Record.get @"filePath" opts
Text.putStrLn $ Maybe.maybe "No file path" Function.id (Record.get @"filePath" opts)
Text.putStrLn $ Show.show @Bool $ Record.get @"quiet" opts

0 comments on commit 484b2ee

Please sign in to comment.