Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #!/usr/bin/env stack
  2. -- stack --resolver=lts-3.18 runghc --package=shelly
  3.  
  4. {-# LANGUAGE OverloadedStrings #-}
  5. {-# LANGUAGE DeriveDataTypeable #-} --TODO: temporary attr
  6. import Control.Monad
  7. import Shelly
  8. import System.Console.CmdArgs
  9.  
  10. -- CLI options
  11. data NicoVideoDlArgs = NicoVideoDlArgs { nicoUsername :: String
  12. , nicoPassword :: String
  13. , nicoTargetId :: String
  14. }
  15. deriving (Show, Data, Typeable) -- TODO: temporary attr
  16. nicoVideoDlArgs :: NicoVideoDlArgs
  17. nicoVideoDlArgs = NicoVideoDlArgs
  18. { nicoUsername = "" &= name "username" &= explicit &= help "Your niconico email-address"
  19. , nicoPassword = "" &= name "password" &= explicit &= help "Your niconico acount password"
  20. , nicoTargetId = "" &= name "target" &= explicit &= help "Download target ID (for example: 'sm24868743')"
  21.  
  22. main :: IO ()
  23. main = do
  24. print "foo"
  25. account <- getAccount
  26. print account
  27.  
  28. -- Get completely account data
  29. getAccount :: IO NicoVideoDlArgs
  30. getAccount = do
  31. account <- cmdargs nicoVideoDlArgs
  32. username <- do
  33. if (not . null $ nicoUsername account) then
  34. return $ nicoUsername account
  35. else
  36. return $ "udonge.like@gmail.com" -- FIXME: temporary
  37. return NicoVideoDlArgs { nicoUsername = username
  38. , nicoPassword = "foo"
  39. , nicoTargetId = "sm24868743"
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement