From 66253bf13e12bdf6c14d9479abf9430ffbef8116 Mon Sep 17 00:00:00 2001 From: Dennis Gosnell Date: Sat, 8 Jun 2024 12:36:50 +0900 Subject: [PATCH] Add a little documentation --- README.md | 12 +++++++++- cqg-cms-api-proto/CHANGELOG.md | 11 --------- cqg-cms-api-proto/README.md | 2 ++ cqg-cms-api-proto/cqg-cms-api-proto.cabal | 4 +++- cqg-cms-api-proto/generate.sh | 25 ------------------- cqg-cms-api-proto/package.yaml | 1 - generate.sh | 29 +++++++++++++++++++++++ 7 files changed, 45 insertions(+), 39 deletions(-) delete mode 100644 cqg-cms-api-proto/CHANGELOG.md delete mode 100755 cqg-cms-api-proto/generate.sh create mode 100755 generate.sh diff --git a/README.md b/README.md index e2451b3..1186ce1 100644 --- a/README.md +++ b/README.md @@ -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 +``` diff --git a/cqg-cms-api-proto/CHANGELOG.md b/cqg-cms-api-proto/CHANGELOG.md deleted file mode 100644 index ec8eae6..0000000 --- a/cqg-cms-api-proto/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# Changelog for `cqg-cms-api-proto` - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to the -[Haskell Package Versioning Policy](https://pvp.haskell.org/). - -## Unreleased - -## 0.1.0.0 - YYYY-MM-DD diff --git a/cqg-cms-api-proto/README.md b/cqg-cms-api-proto/README.md index 0e9d6ec..63bb720 100644 --- a/cqg-cms-api-proto/README.md +++ b/cqg-cms-api-proto/README.md @@ -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). diff --git a/cqg-cms-api-proto/cqg-cms-api-proto.cabal b/cqg-cms-api-proto/cqg-cms-api-proto.cabal index 9fcc5fd..bd7d1ae 100644 --- a/cqg-cms-api-proto/cqg-cms-api-proto.cabal +++ b/cqg-cms-api-proto/cqg-cms-api-proto.cabal @@ -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 @@ -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 @@ -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 diff --git a/cqg-cms-api-proto/generate.sh b/cqg-cms-api-proto/generate.sh deleted file mode 100755 index 2400f6b..0000000 --- a/cqg-cms-api-proto/generate.sh +++ /dev/null @@ -1,25 +0,0 @@ -#! /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 CMS API Protobuf files. - -# Make sure shellcheck understands that this is a Bash script. -# shellcheck shell=bash - -set -eumo pipefail - -shopt -s globstar - -rm -rf proto/* -curl 'https://partners.cqg.com/cms/protocol/production/CMS.zip' > proto/CMS.zip -unzip proto/CMS.zip -d proto/ -rm proto/CMS.zip - -rm -rf src/* -protoc --plugin=protoc-gen-haskell="$(which proto-lens-protoc)" --haskell_out=src/ --proto_path=proto proto/**/*.proto diff --git a/cqg-cms-api-proto/package.yaml b/cqg-cms-api-proto/package.yaml index 477a3e2..138f054 100644 --- a/cqg-cms-api-proto/package.yaml +++ b/cqg-cms-api-proto/package.yaml @@ -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" diff --git a/generate.sh b/generate.sh new file mode 100755 index 0000000..dbbd4f2 --- /dev/null +++ b/generate.sh @@ -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