feat(users/Profpatsch/netencode): add record-splice-env
Splice a netencode record from stdin into the environment. Change-Id: I7eac19e18164e070e4463ee431d9b0e955857b9c Reviewed-on: https://cl.tvl.fyi/c/depot/+/2454 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
parent
3877243211
commit
cf3aab3b78
1 changed files with 25 additions and 0 deletions
|
@ -89,11 +89,36 @@ let
|
|||
} (builtins.readFile ./netencode-mustache.rs);
|
||||
|
||||
|
||||
record-splice-env = imports.writers.rustSimple {
|
||||
name = "record-splice-env";
|
||||
dependencies = [
|
||||
netencode-rs
|
||||
depot.users.Profpatsch.execline.exec-helpers
|
||||
];
|
||||
} ''
|
||||
extern crate netencode;
|
||||
extern crate exec_helpers;
|
||||
use netencode::dec::{Record, ScalarAsBytes, Decoder, DecodeError};
|
||||
fn main() {
|
||||
let t = netencode::t_from_stdin_or_panic("record-splice-env");
|
||||
match Record::<ScalarAsBytes>::dec(t) {
|
||||
Ok(map) => {
|
||||
exec_helpers::exec_into_args(
|
||||
"record-splice-env",
|
||||
map.iter().map(|(k,v)| (k.as_bytes(), &v[..])
|
||||
);
|
||||
},
|
||||
Err(DecodeError(err)) => panic!("{}", err),
|
||||
}
|
||||
}
|
||||
'';
|
||||
|
||||
in {
|
||||
inherit
|
||||
netencode-rs
|
||||
netencode-rs-tests
|
||||
netencode-mustache
|
||||
record-splice-env
|
||||
gen
|
||||
;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue