servant-cli 0.1.0.1 → 0.1.0.2
raw patch · 5 files changed
+34/−15 lines, 5 filesdep ~basedep ~functor-combinators
Dependency ranges changed: base, functor-combinators
Files
- CHANGELOG.md +9/−0
- README.md +3/−0
- example/greet.hs +13/−6
- servant-cli.cabal +7/−7
- src/Servant/CLI/Internal/PStruct.hs +2/−2
CHANGELOG.md view
@@ -1,6 +1,15 @@ Changelog ========= +Version 0.1.0.2+---------------++*November 18, 2019*++<https://github.com/mstksg/servant-cli/releases/tag/v0.1.0.2>++* Update to support *functor-combinators-0.2.0.0*+ Version 0.1.0.1 ---------------
README.md view
@@ -47,6 +47,7 @@ ```haskell main :: IO ()+main = do c <- parseClient testApi (Proxy :: Proxy ClientM) $ header "greet" <> progDesc "Greet API"@@ -78,6 +79,7 @@ ```haskell main :: IO ()+main = do c <- parseHandleClient testApi (Proxy :: Proxy ClientM) (header "greet" <> progDesc "Greet API") $ (\g -> "Greeting: " ++ T.unpack g)@@ -134,6 +136,7 @@ ```haskell main :: IO ()+main = do c <- parseHandleClientWithContext testApi (Proxy :: Proxy ClientM)
example/greet.hs view
@@ -109,6 +109,13 @@ | p == p' -> Authorized <$> randomIO @Int | otherwise -> pure BadPassword +-- | Safely shutdown the server when we're done+withServer :: IO () -> IO ()+withServer action =+ bracket (forkIO $ run 8081 server)+ killThread+ (const action)+ main :: IO () main = do c <- parseHandleClientWithContext@@ -122,14 +129,14 @@ ) :<|> (\s -> "Reversed: " ++ T.unpack s) - _ <- forkIO $ run 8081 server+ withServer $ do - manager' <- newManager defaultManagerSettings- res <- runClientM c (mkClientEnv manager' (BaseUrl Http "localhost" 8081 ""))+ manager' <- newManager defaultManagerSettings+ res <- runClientM c (mkClientEnv manager' (BaseUrl Http "localhost" 8081 "")) - case res of- Left e -> throwIO e- Right rstring -> putStrLn rstring+ case res of+ Left e -> throwIO e+ Right rstring -> putStrLn rstring where cinfo = header "greet" <> progDesc "Greet API" getPwd :: ContextFor ClientM (BasicAuth "login" Int)
servant-cli.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: cc77d286e5084052ae5e3a6a33247742fcfc01d72b8da6244b83f5d4a57f8fbb+-- hash: 2b3be37a4d1cceed3c1f581c09874aba5568f57a825e12c11bfe52f4034673e4 name: servant-cli-version: 0.1.0.1+version: 0.1.0.2 synopsis: Command line interface for Servant API clients description: Parse command line arguments into a servant client, from a servant API, using /optparse-applicative/ for parsing, displaying help, and@@ -26,7 +26,7 @@ copyright: (c) Justin Le 2019 license: BSD3 license-file: LICENSE-tested-with: GHC >= 8.4+tested-with: GHC >= 8.6 build-type: Simple extra-source-files: README.md@@ -48,13 +48,13 @@ src ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wredundant-constraints -Werror=incomplete-patterns build-depends:- base >=4.11 && <5+ base >=4.12 && <5 , bytestring , case-insensitive , containers , filepath , free- , functor-combinators+ , functor-combinators >=0.2 , http-types , optparse-applicative , profunctors@@ -76,7 +76,7 @@ ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wredundant-constraints -Werror=incomplete-patterns build-depends: aeson- , base >=4.11 && <5+ , base >=4.12 && <5 , bytestring , containers , http-client
src/Servant/CLI/Internal/PStruct.hs view
@@ -184,7 +184,7 @@ f <$> argParser a <*> infoParser (structParser_ p False (ps ++ [':' : argName a]) mempty) mkArgs :: Day MultiArg EndpointMap x -> Parser x- mkArgs = upgradeC @Day (Proxy @Parser) $+ mkArgs = unsafeApply (Proxy @Parser) $ forwards . ( Backwards . (\case MultiArg a -> many (argParser a)) !*! Backwards . methodPicker@@ -215,7 +215,7 @@ where epMap = mkEndpoint <$> eps mkEndpoint :: Endpoint x -> Parser x- mkEndpoint = upgradeC @Day (Proxy @Parser) $+ mkEndpoint = unsafeApply (Proxy @Parser) $ binterpret (interpret mkOpt) id . epStruct pickMethod :: HTTP.Method -> Parser x -> Mod CommandFields x