packages feed

clit 0.3.0.2 → 0.3.0.3

raw patch · 4 files changed

+53/−7 lines, 4 filesdep ~clit

Dependency ranges changed: clit

Files

clit.cabal view
@@ -1,5 +1,5 @@ name: clit-version: 0.3.0.2+version: 0.3.0.3 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -23,6 +23,11 @@     type: git     location: https://github.com/vmchale/command-line-tweeter +flag llvm-fast+    description:+        Enable build with llvm backend+    default: False+ library     exposed-modules:         Web.Tweet@@ -51,11 +56,15 @@         Web.Tweet.Sign  executable tweet+    +    if flag(llvm-fast)+        ghc-options: -threaded -rtsopts -with-rtsopts=-N -fllvm -optlo-O3 -O3+    else+        ghc-options: -threaded -rtsopts -with-rtsopts=-N     main-is: Main.hs     build-depends:         base >=4.9.1.0 && <4.10,-        clit >=0.3.0.2 && <0.4+        clit >=0.3.0.3 && <0.4     default-language: Haskell2010     hs-source-dirs: app-    ghc-options: -threaded -rtsopts -with-rtsopts=-N 
src/Web/Tweet.hs view
@@ -30,6 +30,8 @@     , urlString     , getTimeline     , showTimeline+    , getProfile+    , showProfile     ) where  import Network.HTTP.Client@@ -99,7 +101,18 @@     request <- signRequest filepath $ initialRequest { method = "POST" }     responseInt request manager -showTimeline count color filepath = replace "\\n" "\n" . replace "\\/" "/" . fromRight . (fmap (if color then displayTimelineColor else displayTimeline)) <$> getTimeline count filepath+getProfile screenName count filepath = do+    let requestString = "?screen_name=" ++ screenName ++ "&count=" ++ (show count)+    manager <- newManager tlsManagerSettings+    initialRequest <- parseRequest ("https://api.twitter.com/1.1/statuses/user_timeline.json" ++ requestString)+    request <- signRequest filepath $ initialRequest { method = "GET"}+    getTweets . BSL.unpack <$> responseBS request manager++showProfile screenName count color filepath = showTweets color <$> getProfile screenName count filepath++showTimeline count color filepath = showTweets color <$> getTimeline count filepath++showTweets color = replace "\\n" "\n" . replace "\\/" "/" . fromRight . (fmap (if color then displayTimelineColor else displayTimeline))     where fromRight (Right a) = a  getTimeline count filepath = do
src/Web/Tweet/Exec.hs view
@@ -12,7 +12,7 @@ -- | Data type for our program: one optional path to a credential file, (optionally) the number of tweets to make, the id of the status you're replying to, and a list of users you wish to mention. data Program = Program { subcommand :: Command , cred :: Maybe FilePath } -data Command = Timeline { count :: Maybe Int , color :: Bool } | Send { tweets :: Maybe Int, replyId :: Maybe String, replyHandles :: Maybe [String] }+data Command = Timeline { count :: Maybe Int , color :: Bool } | Send { tweets :: Maybe Int, replyId :: Maybe String, replyHandles :: Maybe [String] } | Profile { count :: Maybe Int , color :: Bool , screenName :: String }  -- | query twitter to post stdin with no fancy options fromStdIn :: Int -> FilePath -> IO ()@@ -55,13 +55,22 @@ select (Program (Timeline Nothing True) (Just file)) = putStrLn =<< showTimeline 8 True file select (Program (Timeline (Just n) True) (Just file)) = putStrLn =<< showTimeline 8 True file select (Program (Timeline (Just n) True) Nothing) = putStrLn =<< showTimeline 8 True ".cred"+select (Program (Profile (Just n) True name) (Just file)) = putStrLn =<< showProfile name n True file+select (Program (Profile Nothing True name) (Just file)) = putStrLn =<< showProfile name 12 True file+select (Program (Profile (Just n) True name) Nothing) = putStrLn =<< showProfile name n True ".cred"+select (Program (Profile Nothing True name) Nothing) = putStrLn =<< showProfile name 12 True ".cred"+select (Program (Profile (Just n) False name) (Just file)) = putStrLn =<< showProfile name n False file+select (Program (Profile Nothing False name) (Just file)) = putStrLn =<< showProfile name 12 False file+select (Program (Profile (Just n) False name) Nothing) = putStrLn =<< showProfile name n False ".cred"+select (Program (Profile Nothing False name) Nothing) = putStrLn =<< showProfile name 12 False ".cred"  -- | Parser to return a program datatype program :: Parser Program program = Program     <$> (hsubparser         (command "send" (info tweet (progDesc "Send a tweet"))-        <> command "view" (info timeline (progDesc "Get your timeline"))))+        <> command "view" (info timeline (progDesc "Get your timeline"))+        <> command "user" (info profile (progDesc "Get a user's profile"))))     <*> (optional $ strOption         (long "cred"         <> short 'c'@@ -79,6 +88,21 @@         (long "color"         <> short 'l'         <> help "Display timeline with colorized terminal output.")++profile :: Parser Command+profile = Profile+    <$> (optional $ read <$> strOption+        (long "count"+        <> short 'n'+        <> metavar "NUM"+        <> help "Number of tweets to fetch, default 12"))+    <*> switch+        (long "color"+        <> short 'l'+        <> help "Whether to display profile with colorized terminal output")+    <*> argument str+        (metavar "SCREEN_NAME"+        <> help "Screen name of user you want to view.")  tweet :: Parser Command tweet = Send
src/Web/Tweet/Utils.hs view
@@ -16,7 +16,7 @@ --toUnicode "\u00e9" =   displayTimelineColor :: Timeline -> String-displayTimelineColor ((user,content):rest) = ((show . yellow . text $ user) <> ":\n    " <> content <> "\n") <> (displayTimeline rest)+displayTimelineColor ((user,content):rest) = ((show . yellow . text $ user) <> ":\n    " <> content <> "\n") <> (displayTimelineColor rest) displayTimelineColor [] = []  displayTimeline :: Timeline -> String