Skip to content

Commit

Permalink
Support passing arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdone committed Aug 23, 2024
1 parent 7eabe72 commit e3b789f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Hell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ data Command
| Version

main :: IO ()
main = dispatch =<< Options.execParser opts
main = do
args <- getArgs
case args of
(x:ys)
| not (List.isPrefixOf "-" x) -> withArgs ys $ dispatch (Run x)
_ -> dispatch =<< Options.execParser opts
where
opts = Options.info (commandParser Options.<**> Options.helper)
( Options.fullDesc
Expand Down
3 changes: 3 additions & 0 deletions examples/23-args.hell
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
main = do
args <- Environment.getArgs
Monad.forM_ args IO.print

0 comments on commit e3b789f

Please sign in to comment.