Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cdepillabout committed Jun 5, 2024
1 parent 6e5f233 commit d2ac16f
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 23 deletions.
48 changes: 48 additions & 0 deletions cqg-cms-api-client/app/cqg-cms-example/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

module Main where

import Lib

import Wuss


-- | Get a 'String' environment variable.
getEnv ::
-- | Environment variable to lookup
String ->
-- | Default value to use if the environment variable is not set.
String ->
IO String
getEnv envVar defVal = fromMaybe defVal <$> lookupEnv envVar


-- | Similar to 'getEnv', but read in a value with 'read'.
--
-- Throws an exception if the environment variable is set, but the value can't be 'read'.
getFromEnv ::
Read a =>
-- | Environment variable to lookup
String ->
-- | Default value to use if the environment variable is not set.
a ->
IO a
getFromEnv envVar defVal = do
maybeRes <- lookupEnv envVar
case maybeRes of
Nothing -> pure defVal
Just strRes -> do
case readMay strRes of
Nothing ->
error $ "Can't read environment variable " <> envVar <> " value: " <> strRes
Just res -> pure res


main :: IO ()
main = do
hostname <- getEnv "CQG_WEBSOCKETS_HOSTNAME" "democmsapi.cqg.com"
port <- getFromEnv "CQG_WEBSOCKETS_PORT" 443
path <- getEnv "CQG_WEBSOCKETS_PATH" "/"
runSecureClient hostname port path app

app :: IO ()
app = undefined
17 changes: 17 additions & 0 deletions cqg-cms-api-client/cqg-cms-api-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,21 @@ library
build-depends:
base >=4.7 && <5
, cqg-cms-api-proto
, websockets
, wuss
default-language: Haskell2010

executable cqg-cms-example
main-is: Main.hs
other-modules:
Paths_cqg_cms_api_client
hs-source-dirs:
app/cqg-cms-example
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -Wno-unused-do-bind -Wunused-packages -funbox-strict-fields -fwrite-ide-info -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, cqg-cms-api-client
, cqg-cms-api-proto
, websockets
, wuss
default-language: Haskell2010
58 changes: 35 additions & 23 deletions cqg-cms-api-client/package.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
name: "cqg-cms-api-client"
version: "0.1.0.0"
maintainer: "Bitnomial <[email protected]>"
license: "AllRightsReserved"
author: "Bitnomial"
copyright: "2024 Bitnomial, Inc"
name: "cqg-cms-api-client"
version: "0.1.0.0"
maintainer: "Bitnomial <[email protected]>"
license: "AllRightsReserved"
author: "Bitnomial"
copyright: "2024 Bitnomial, Inc"

extra-source-files:
- README.md
- CHANGELOG.md
- proto/**/*.proto

synopsis: "CQG CMS API websocket client"
category: "Web"
synopsis: "CQG CMS API websocket client"
category: "Web"

# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description: "Please see the README on GitHub at <https://github.com/bitnomial/cqg-api-client/cqg-cms-api-client#readme>"
description: "Please see the README on GitHub at <https://github.com/bitnomial/cqg-api-client/cqg-cms-api-client#readme>"

dependencies:
- base >= 4.7 && < 5
- cqg-cms-api-proto
- websockets
- wuss

ghc-options:
- -Wall
- -Wcompat
- -Widentities
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wmissing-export-lists
- -Wmissing-home-modules
- -Wpartial-fields
- -Wredundant-constraints
- -Wno-unused-do-bind
- -Wunused-packages
- -funbox-strict-fields
- -fwrite-ide-info
- "-Wall"
- "-Wcompat"
- "-Widentities"
- "-Wincomplete-record-updates"
- "-Wincomplete-uni-patterns"
- "-Wmissing-export-lists"
- "-Wmissing-home-modules"
- "-Wpartial-fields"
- "-Wredundant-constraints"
- "-Wno-unused-do-bind"
- "-Wunused-packages"
- "-funbox-strict-fields"
- "-fwrite-ide-info"

library:
source-dirs: src

executables:
cqg-cms-example:
main: "Main.hs"
source-dirs: "app/cqg-cms-example"
ghc-options:
- "-threaded"
- "-rtsopts"
- "-with-rtsopts=-N"
dependencies:
- cqg-cms-api-client

0 comments on commit d2ac16f

Please sign in to comment.