From 2b0ee72ceb309c1ceed97574922ccc1c9d5ae02a Mon Sep 17 00:00:00 2001 From: Alex Helfet Date: Wed, 27 Dec 2017 21:28:15 +0000 Subject: [PATCH] bin/decode_typed can run decode with a type and crate passed via environment variables. Issue #9. --- Cargo.lock | 1 - bin/decode_typed | 49 +++++++++++++++++++++++++++++++++++++++++++ decode/Cargo.toml | 1 - decode/README.md | 10 +++++++++ decode/src/dynamic.rs | 5 ----- decode/src/main.rs | 2 +- 6 files changed, 60 insertions(+), 8 deletions(-) create mode 100755 bin/decode_typed create mode 100644 decode/README.md delete mode 100644 decode/src/dynamic.rs diff --git a/Cargo.lock b/Cargo.lock index 48e57cb..c540f11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,7 +75,6 @@ dependencies = [ "clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive-error 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "framed 0.1.4", - "framed_test_type 0.1.0", ] [[package]] diff --git a/bin/decode_typed b/bin/decode_typed new file mode 100755 index 0000000..03ceb10 --- /dev/null +++ b/bin/decode_typed @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +set -e + +REPO_DIR="$(cd $(dirname ${BASH_SOURCE[0]} )/..; pwd )" + +TYPE_CRATE_DIR="${TYPE_CRATE_DIR-${REPO_DIR}/test_type}" +TYPE_NAME="${TYPE_NAME-framed_test_type::Test}" + +echo "TYPE_CRATE_DIR = '${TYPE_CRATE_DIR}'" +echo "TYPE_NAME = '${TYPE_NAME}'" + +TYPE_CRATE_NAME="$(cargo read-manifest --manifest-path "${TYPE_CRATE_DIR}/Cargo.toml" | jq '.name' -r)" + +TMP_DIR="${REPO_DIR}/target/decode_typed/tmp" + +mkdir -p "${TMP_DIR}"; +rm -f "${TMP_DIR}/"*; + +# TODO: Move dynamic.rs to TMP_DIR, both here and in the include! in main.rs. +export FRAMED_DECODE_DYNAMIC_RS="${TMP_DIR}/dynamic_${TYPE_NAME}.rs"; +cat > "${FRAMED_DECODE_DYNAMIC_RS}" <