PastePipe 1.7 → 1.8
raw patch · 3 files changed
+53/−35 lines, 3 filesdep +PastePipePVP ok
version bump matches the API change (PVP)
Dependencies added: PastePipe
API changes (from Hackage documentation)
+ Utils.PastePipe: mkPrivatePair :: Config -> (String, String)
+ Utils.PastePipe: private :: Config -> Bool
- Utils.PastePipe: Config :: String -> String -> String -> String -> String -> Bool -> Config
+ Utils.PastePipe: Config :: String -> String -> String -> String -> String -> Bool -> Bool -> Config
Files
- PastePipe.cabal +8/−5
- src/Main.hs +1/−1
- src/Utils/PastePipe.hs +44/−29
PastePipe.cabal view
@@ -1,5 +1,5 @@ name: PastePipe-version: 1.7+version: 1.8 synopsis: CLI for pasting to lpaste.net description: PastePipe reads from standard in and posts to <lpaste.net>. It will auto-detect your username, but that can be@@ -12,17 +12,20 @@ bug-reports: http://github.com/Fuuzetsu/pastepipe/issues author: Rogan Creswick maintainer: fuuzetsu@fuuzetsu.co.uk-Cabal-Version: >=1.4+Cabal-Version: >=1.8 build-type: Simple Executable pastepipe- hs-source-dirs: src- Main-is: Main.hs- Build-Depends: base >= 4 && < 5, HTTP, network, cmdargs, network-uri+ Main-is: src/Main.hs+ Build-Depends: base >= 4 && < 5, cmdargs, PastePipe ghc-options: -Wall library hs-source-dirs: src exposed-modules: Utils.PastePipe Build-Depends: base >= 4 && < 5, HTTP, network, cmdargs, network-uri++source-repository head+ type: git+ location: https://github.com/Fuuzetsu/PastePipe.git
src/Main.hs view
@@ -1,7 +1,7 @@ -- | -- Module : Main -- Copyright : (c) Ragon Creswick, 2009-2012--- Mateusz Kowalczyk, 2014+-- Mateusz Kowalczyk, 2014-2015 -- License : GPL-3 -- -- Entry point for the executable, using "Utils.PastePipe".
src/Utils/PastePipe.hs view
@@ -2,7 +2,7 @@ -- | -- Module : Utils.PastePipe -- Copyright : (c) Ragon Creswick, 2009-2012--- Mateusz Kowalczyk, 2014+-- Mateusz Kowalczyk, 2014-2015 -- License : GPL-3 -- -- Configuration and communication with lpaste.net@@ -22,37 +22,43 @@ , channel :: String , title :: String , uri :: String- , test :: Bool }+ , private :: Bool+ , test :: Bool+ } deriving (Show, Data, Typeable) +-- | Default config builder config :: String -> Config-config realUser = Config { userName = realUser- &= help "Your user name"- &= typ "USER"- &= explicit- &= name "user"- , language = "haskell"- &= help "The language used for syntax highlighting"- &= typ "LANGUAGE"- , channel = ""- &= help "#channel to post your snippet. The lpaste bot will not post the message if you do not set --title=TITLE and --user=<YOUR NICK>"- &= typ "#channel-name"- &= name "channel"- &= name "c"- , title = ""- &= help "The title of the snippet"- &= typ "TITLE"- &= explicit- &= name "title"- &= name "t"- , uri = defaultUri- &= help "The URI of the lpaste instance to post to"- &= typ "URL"- , test = False- &= help "Prevents PastePipe from actually posting content, just echos the configuration and input"- }- &= summary "PastePipe v1.3, (C) Rogan Creswick 2009"- &= program "pastepipe"+config realUser = Config+ { userName = realUser+ &= help "Your user name"+ &= typ "USER"+ &= explicit+ &= name "user"+ , language = "haskell"+ &= help "The language used for syntax highlighting"+ &= typ "LANGUAGE"+ , channel = ""+ &= help "#channel to post your snippet. The lpaste bot will not post the message if you do not set --title=TITLE and --user=<YOUR NICK>"+ &= typ "#channel-name"+ &= name "channel"+ &= name "c"+ , title = ""+ &= help "The title of the snippet"+ &= typ "TITLE"+ &= explicit+ &= name "title"+ &= name "t"+ , uri = defaultUri+ &= help "The URI of the lpaste instance to post to"+ &= typ "URL"+ , private = False+ &= help "Make this a private snippet, off by default"+ , test = False+ &= help "Prevents PastePipe from actually posting content, just echos the configuration and input"+ }+ &= summary "PastePipe v1.8, (C) Rogan Creswick 2009-2012, (C) Mateusz Kowalczyk 2014-2015"+ &= program "pastepipe" -- | Takes a string to post to the default and returns the URI. -- Client code is expected to catch any exceptions.@@ -87,6 +93,11 @@ request $ buildRequest conf str return url +-- | Make a pair suitable for encoding out of 'private' setting.+mkPrivatePair :: Config -> (String, String)+mkPrivatePair conf | private conf = ("private", "Private")+ | otherwise = ("public", "Public")+ -- | Creates the request to post a chunk of content. buildRequest :: Config -> String -> Request String buildRequest conf str = formToRequest $ Form POST (saveUri $ uri conf)@@ -95,9 +106,12 @@ , ("paste", str) , ("language", language conf) , ("channel", channel conf)+ , mkPrivatePair conf , ("email", "") ] +-- | Just print out the fields and the 'URI' that we would have used+-- if we ran with the given 'Config'. fakePost :: Config -> String -> IO URI fakePost conf str = do putStrLn $ "uri: "++uri conf@@ -106,4 +120,5 @@ putStrLn $ "chan: "++channel conf putStrLn $ "title: "++title conf putStrLn $ "content: "++str+ putStrLn $ (\(p, p') -> p ++ ":" ++ p') (mkPrivatePair conf) return $ fromJust $ parseURI $ uri conf