-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e5f233
commit d2ac16f
Showing
3 changed files
with
100 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |