Skip to content

Commit

Permalink
Add a little documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cdepillabout committed Jun 8, 2024
1 parent 76735aa commit 66253bf
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 39 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@

This repo contains Haskell packages for working with CQG's APIs:

- [CQG CMS API](https://partners.cqg.com/api-resources/cms-api)
- [CQG CMS API](https://partners.cqg.com/api-resources/cms-api) [`./cqg-cms-api-proto`](./cqg-cms-api-proto/)
- [CQG Web API](https://partners.cqg.com/api-resources/web-api) (_not yet implemented_)

## Regenerating Haskell modules

You can redownload the protobuf files for CQG's APIs, and then regenerate the
Haskell modules with the following command. This is a `nix-shell` script, so
make sure you have Nix installed before running this command:

```console
$ ./generate.sh
```
11 changes: 0 additions & 11 deletions cqg-cms-api-proto/CHANGELOG.md

This file was deleted.

2 changes: 2 additions & 0 deletions cqg-cms-api-proto/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# cqg-cms-api-proto

This package contains Haskell modules generated from the protobuf files for CQG's [CMS API](https://partners.cqg.com/api-resources/cms-api/documentation).
4 changes: 3 additions & 1 deletion cqg-cms-api-proto/cqg-cms-api-proto.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ license-file: LICENSE
build-type: Simple
extra-source-files:
README.md
CHANGELOG.md
proto/CMS/api_limit_1.proto
proto/CMS/cmsapi_1.proto
proto/CMS/common_1.proto
Expand All @@ -26,6 +25,7 @@ extra-source-files:
proto/CMS/login_1.proto
proto/CMS/metadata_1.proto
proto/CMS/order_1.proto
proto/CMS/profile_1.proto
proto/CMS/session_context_1.proto
proto/CMS/traderouting_1.proto
proto/common/decimal.proto
Expand All @@ -49,6 +49,8 @@ library
Proto.CMS.Metadata1_Fields
Proto.CMS.Order1
Proto.CMS.Order1_Fields
Proto.CMS.Profile1
Proto.CMS.Profile1_Fields
Proto.CMS.SessionContext1
Proto.CMS.SessionContext1_Fields
Proto.CMS.Traderouting1
Expand Down
25 changes: 0 additions & 25 deletions cqg-cms-api-proto/generate.sh

This file was deleted.

1 change: 0 additions & 1 deletion cqg-cms-api-proto/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ copyright: "2024 Bitnomial, Inc"

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

synopsis: "Haskell modules generated from Protobuf definitions of the CQG CMS API"
Expand Down
29 changes: 29 additions & 0 deletions generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash
# nixos-24.05 as of 2024-06-01
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/805a384895c696f802a9bf5bf4720f37385df547.tar.gz
#! nix-shell -p curl
#! nix-shell -p unzip
#! nix-shell -p protobuf
#! nix-shell -p haskellPackages.proto-lens-protoc
#
# This script will download and regenerate the CQG API Protobuf files.

# Make sure shellcheck understands that this is a Bash script:
# shellcheck shell=bash

set -eumo pipefail

shopt -s globstar

# Download the protobuf files

rm -rf cqg-cms-api-proto/proto/*
curl 'https://partners.cqg.com/cms/protocol/production/CMS.zip' > cqg-cms-api-proto/proto/CMS.zip
unzip cqg-cms-api-proto/proto/CMS.zip -d cqg-cms-api-proto/proto/
rm cqg-cms-api-proto/proto/CMS.zip

# Generate the Haskell modules from the protobuf files

rm -rf cqg-cms-api-proto/src/*
protoc --plugin=protoc-gen-haskell="$(which proto-lens-protoc)" --haskell_out=cqg-cms-api-proto/src/ --proto_path=cqg-cms-api-proto/proto cqg-cms-api-proto/proto/**/*.proto

0 comments on commit 66253bf

Please sign in to comment.