From 9fd02f49809bfdfef205fae5885636eef0a69b21 Mon Sep 17 00:00:00 2001 From: defanor Date: Sun, 3 Dec 2017 10:00:27 +0300 Subject: Parse lists of strings, not just strings Because arguments are lists of strings. --- Example.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Example.hs') diff --git a/Example.hs b/Example.hs index 6454fc7..fca8165 100644 --- a/Example.hs +++ b/Example.hs @@ -16,7 +16,7 @@ instance ToArgs RecTest data Foo = Bar Int | Baz Int - | Qux (Maybe Int) (Maybe Int) RecTest (Maybe Double) + | Qux (Maybe Int) (Maybe String) RecTest (Maybe Double) deriving (Generic, Show) instance ArgParser Foo @@ -30,8 +30,9 @@ instance ToArgs Wrap main :: IO () main = do - let val = Wrap (Just $ Qux Nothing (Just 1) (RecTest Nothing (Just 2.3) Nothing) Nothing) (Just 1) - a = args defMod val + let val = Wrap (Just $ Qux Nothing (Just "foo bar") + (RecTest Nothing (Just 2.3) Nothing) Nothing) (Just 1) + a = toArgs defMod val print val - putStrLn a + print a print $ parse (argParser defMod :: Parser Wrap) "test" a -- cgit v1.2.3