module App.Interact ( startParser ) where import Options.Applicative import System.IO ( stdout, hFlush, hSetEcho ) import App.Options ( optparser, Options (..) ) import App.Cycle ( startCycle ) startParser :: IO () startParser = execParser desc >>= route where imod = helper <*> optparser desc = info imod $ fullDesc <> progDesc "Login daily to the stackoverflow website" <> header "so-daily - automatic scheduled SO login" route :: Options -> IO () route (Options r v e "") = do -- The password was not given, let's ask it putStr "Password: " hFlush stdout hSetEcho stdout False p <- getLine putStrLn "" hSetEcho stdout True startCycle $ Options r v e p route opts = startCycle opts