tweet-hs 1.0.1.7 → 1.0.1.8
raw patch · 8 files changed
+39/−93 lines, 8 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Web.Tweet: showNoReplies :: String -> Int -> Bool -> FilePath -> IO String
+ Web.Tweet.Exec: [withReplies] :: Command -> Bool
- Web.Tweet.Exec: Profile :: Maybe Int -> Maybe String -> Command
+ Web.Tweet.Exec: Profile :: Maybe Int -> Maybe String -> Bool -> Command
Files
- README.md +8/−0
- cabal.project.local +5/−0
- src/Web/Tweet/API/Internal.hs +4/−0
- src/Web/Tweet/Exec.hs +7/−2
- src/Web/Tweet/Parser.hs +10/−20
- src/Web/Tweet/Utils.hs +3/−1
- stack.yaml +0/−68
- tweet-hs.cabal +2/−2
README.md view
@@ -115,6 +115,14 @@ to view your own timeline. +### GHCi integration++You can define the following in your `~/.ghci`++```haskell+:def tweet (\str -> pure $ ":! tweet send \"" ++ str ++ "\"")+```+ ### Completions The directory `bash/` has a `mkCompletions` script to allow command completions for your convenience.
+ cabal.project.local view
@@ -0,0 +1,5 @@+with-compiler: ghc-8.2.1+optimization: 2+documentation: True+haddock-hoogle: True+haddock-internal: True
src/Web/Tweet/API/Internal.hs view
@@ -24,6 +24,10 @@ showTimeline :: Int -> Bool -> FilePath -> IO String showTimeline count color = (fmap (showTweets color)) . getTimeline count +-- | Display a user timeline, filtering out tweets+showNoReplies :: String -> Int -> Bool -> FilePath -> IO String+showNoReplies sn count color = (fmap (showTweets color . fmap filterReplies)) . getProfile sn count+ -- | Display user timeline in color, as appropriate showTweets :: Bool -> Either (ParseError Char Void) Timeline -> String showTweets color = (either show id) . (fmap (if color then displayTimelineColor else displayTimeline))
src/Web/Tweet/Exec.hs view
@@ -19,7 +19,7 @@ -- TODO add boolean option to show ids alongside tweets data Command = Timeline { count :: Maybe Int } | SendInput { tweetInputs :: Maybe Int, replyId :: Maybe String, replyh :: Maybe [String] }- | Profile { count :: Maybe Int , screenName'' :: Maybe String }+ | Profile { count :: Maybe Int , screenName'' :: Maybe String, withReplies :: Bool } | Mentions { count :: Maybe Int } | Markov { screenName' :: String } | Send { tweets :: Maybe Int , replyId :: Maybe String , replyh :: Maybe [String] , userInput :: String }@@ -80,7 +80,8 @@ selectCommand (SendInput maybeNum Nothing (Just h)) _ file = threadStdIn h Nothing (fromMaybe 15 maybeNum) file selectCommand (Timeline maybeNum) c file = putStrLn =<< showTimeline (fromMaybe 11 maybeNum) c file selectCommand (Mentions maybeNum) c file = putStrLn =<< showTweets c <$> mentions (fromMaybe 11 maybeNum) file-selectCommand (Profile maybeNum n) c file = putStrLn =<< showProfile (fromMaybe mempty n) (fromMaybe 11 maybeNum) c file+selectCommand (Profile maybeNum n False) c file = putStrLn =<< showProfile (fromMaybe mempty n) (fromMaybe 11 maybeNum) c file+selectCommand (Profile maybeNum n True) c file = putStrLn =<< showNoReplies (fromMaybe mempty n) (fromMaybe 11 maybeNum) c file selectCommand (Sort n maybeNum False) c file = putStrLn =<< showBest' n (fromMaybe 11 maybeNum) c file selectCommand (Sort n maybeNum True) c file = putStrLn =<< showBest n (fromMaybe 11 maybeNum) c file selectCommand (List maybeNum n) c file = putStrLn =<< showFavorites (fromMaybe 11 maybeNum) n c file@@ -250,6 +251,10 @@ <> metavar "NUM" <> help "Number of tweetInputs to fetch, default 12")) <*> optional user+ <*> switch (+ long "no-replies"+ <> short 'r'+ <> help "Don't display replies.") -- | Parser for the mention subcommand mentionsParser :: Parser Command
src/Web/Tweet/Parser.hs view
@@ -4,6 +4,7 @@ module Web.Tweet.Parser ( parseTweet , getData ) where +import Control.Composition ((.*)) import qualified Data.ByteString as BS import Text.Megaparsec.Byte import Text.Megaparsec.Byte.Lexer as L@@ -55,7 +56,6 @@ case contents of (Just _) -> pure <$> getData _ -> pure Nothing- -- | Skip a set of square brackets [] skipInsideBrackets :: Parser ()@@ -65,10 +65,8 @@ skipMentions :: Parser () skipMentions = do many $ try $ anyChar >> notFollowedBy (string "\"user_mentions\":")- char ','- string "\"user_mentions\":"+ string ",\"user_mentions\":" skipInsideBrackets- pure () -- | Throw out input until we get to a relevant tag. filterStr :: String -> Parser String@@ -104,24 +102,18 @@ -- | Parse a newline newlineChar :: Parser Char-newlineChar = do- string "\\n"- pure '\n'+newlineChar = string "\\n" >> pure '\n' -- | Parser for unicode; twitter will give us something like "/u320a" unicodeChar :: Parser Char-unicodeChar = do- string "\\u"- num <- fromHex . filterEmoji . BS.pack . map (fromIntegral . fromEnum) <$> count 4 anyChar- pure . toEnum . fromIntegral $ num+unicodeChar = toEnum . fromIntegral . f <$> go+ where go = string "\\u" >> count 4 anyChar+ f = fromHex . filterEmoji . BS.pack . fmap (fromIntegral . fromEnum) emojiChar :: Parser Char-emojiChar = do- _ <- string "\\ud"- str1 <- count 3 anyChar- str2 <- string "\\ud" >> count 3 anyChar- let num = decodeUtf16 $ "d" <> str1 <> "d" <> str2- pure . T.head $ num+emojiChar = go a+ where a = string "\\ud" >> count 3 anyChar+ go = (<*>) =<< (((T.head . decodeUtf16) .* ((<>) . (<> "d") . ("d" <>))) <$>) decodeUtf16 :: String -> T.Text decodeUtf16 = TE.decodeUtf16BE . BS.concat . go@@ -147,9 +139,7 @@ -- | Parse escaped characters specialChar :: Char -> Parser Char-specialChar c = do- string $ "\\" <> pure c- pure c+specialChar c = string ("\\" <> pure c) >> pure c -- | Convert a string of four hexadecimal digits to an integer. fromHex :: BS.ByteString -> Integer
src/Web/Tweet/Utils.hs view
@@ -9,7 +9,9 @@ , lineByKey , bird , getConfigData- , filterQuotes ) where+ , filterQuotes+ , filterReplies+ ) where import Control.Composition import Control.Lens hiding (noneOf)
− stack.yaml
@@ -1,68 +0,0 @@-# This file was automatically generated by 'stack init'-#-# Some commonly used options have been documented as comments in this file.-# For advanced use and comprehensive documentation of the format, please see:-# https://docs.haskellstack.org/en/stable/yaml_configuration/--# Resolver to choose a 'specific' stackage snapshot or a compiler version.-# A snapshot resolver dictates the compiler version and the set of packages-# to be used for project dependencies. For example:-#-# resolver: lts-3.5-# resolver: nightly-2015-09-21-# resolver: ghc-7.10.2-# resolver: ghcjs-0.1.0_ghc-7.10.2-# resolver:-# name: custom-snapshot-# location: "./custom-snapshot.yaml"-resolver: lts-9.3--# User packages to be built.-# Various formats can be used as shown in the example below.-#-# packages:-# - some-directory-# - https://example.com/foo/bar/baz-0.0.2.tar.gz-# - location:-# git: https://github.com/commercialhaskell/stack.git-# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# extra-dep: true-# subdirs:-# - auto-update-# - wai-#-# A package marked 'extra-dep: true' will only be built if demanded by a-# non-dependency (i.e. a user package), and its test suites and benchmarks-# will not be run. This is useful for tweaking upstream packages.-packages:-- .-# Dependency packages to be pulled from upstream that are not in the resolver-# (e.g., acme-missiles-0.3)-extra-deps:-- composition-prelude-0.1.0.4-- megaparsec-6.1.1--# Override default flag values for local packages and extra-deps-flags: {}--# Extra package databases containing global packages-extra-package-dbs: []--# Control whether we use the GHC we find on the path-# system-ghc: true-#-# Require a specific version of stack, using version ranges-# require-stack-version: -any # Default-# require-stack-version: ">=1.5"-#-# Override the architecture used by stack, especially useful on Windows-# arch: i386-# arch: x86_64-#-# Extra directories used by stack for building-# extra-include-dirs: [/path/to/dir]-# extra-lib-dirs: [/path/to/dir]-#-# Allow a newer minor version of GHC than the snapshot specifies-# compiler-check: newer-minor
tweet-hs.cabal view
@@ -1,5 +1,5 @@ name: tweet-hs-version: 1.0.1.7+version: 1.0.1.8 synopsis: Command-line tool for twitter description: a Command Line Interface Tweeter homepage: https://github.com/vmchale/command-line-tweeter#readme@@ -11,7 +11,7 @@ category: Web build-type: Simple stability: stable-extra-source-files: README.md, stack.yaml, bash/mkCompletions, test/data+extra-source-files: README.md, cabal.project.local, bash/mkCompletions, test/data cabal-version: >=1.10 Flag llvm-fast {