ws 0.0.1 → 0.0.2
raw patch · 4 files changed
+12/−8 lines, 4 files
Files
- app/Main.hs +10/−4
- src/App.hs +0/−1
- src/App/Types.hs +1/−2
- ws.cabal +1/−1
app/Main.hs view
@@ -12,13 +12,14 @@ import Data.Monoid ((<>)) import Control.Monad.Catch (throwM, handle)+import Control.Applicative (optional) -- * Options Parsing -- | Application-wide options newtype AppOpts = AppOpts- { url :: String+ { url :: Maybe String } -- | Options for each field@@ -26,8 +27,8 @@ appOpts = AppOpts <$> urlOpt where- urlOpt :: Parser String- urlOpt = strArgument $+ urlOpt :: Parser (Maybe String)+ urlOpt = optional $ strArgument $ metavar "TARGET" <> help "The websocket address to connect to - example:\ \ `ws://localhost:3000/foo`"@@ -55,7 +56,12 @@ -- | Translate the CLI parsed options to a sane type we can use in our app appOptsToEnv :: AppOpts -> IO Env-appOptsToEnv (AppOpts u) =+appOptsToEnv (AppOpts mu) = do+ u <- case mu of+ Nothing -> do+ putStrLn "Websocket URI: "+ getLine+ Just x -> pure x case parseURI u of Nothing -> throwM $ URIParseException u Just u' ->
src/App.hs view
@@ -13,7 +13,6 @@ import qualified Data.Text as T import qualified Data.Text.Lazy as LT import qualified Data.Text.Lazy.Encoding as LT-import qualified Data.ByteString.Lazy.Char8 as LBS import Data.Monoid ((<>)) import Control.Monad (forever, unless, void) import Control.Monad.IO.Class (liftIO)
src/App/Types.hs view
@@ -6,9 +6,8 @@ module App.Types where -import Control.Monad.Reader (ReaderT (runReaderT), MonadReader)+import Control.Monad.Reader (ReaderT (runReaderT)) import Control.Monad.Catch (Exception)-import Control.Monad.IO.Class (MonadIO) import System.IO (hPutStr, stderr) import System.Exit (exitFailure)
ws.cabal view
@@ -1,5 +1,5 @@ Name: ws-Version: 0.0.1+Version: 0.0.2 Author: Athan Clark <athan.clark@gmail.com> Maintainer: Athan Clark <athan.clark@gmail.com> License: BSD3