Commits

Konstantine Rybnikov committed 7de4fe7 Draft

Basic test passes.

  • Participants
  • Parent commits 76eb9a9

Comments (0)

Files changed (2)

+module ReadHelp where
+
+import Text.ParserCombinators.Parsec
+
+readHelp :: String -> String
+readHelp s = case parse parser "<unknown>" s of
+  Left err -> "Could not parse. Error: " ++ (show err)
+  Right x -> x
+
+parser :: Parser String
+parser  = string " "
+
+newtype ProgramOption = ProgramOption { unProgramOption :: ([String], String) }
+                      deriving (Eq, Show)
+
+word    :: Parser String
+word    = many1 letter <?> "word"
+
+parseOptions :: Parser [ProgramOption]
+parseOptions = do
+  spaces
+  prefix <- string "--"
+  optionName <- word
+  spaces
+  description <- many anyChar
+  return $ [ProgramOption ([prefix ++ optionName], description)]
   case res of
     True -> qc
     False -> do
-      putStrLn $ (show a) ++ " != " ++ (show b)
+      putStrLn $ (show a) ++ "\n != \n" ++ (show b)
       qc
 
 main = do