(
arg_string: &Option<String>,
arg_path: &Option<String>,
raw_arg: &Option<String>,
)
| 15 | } |
| 16 | |
| 17 | pub(super) fn parse_arguments( |
| 18 | arg_string: &Option<String>, |
| 19 | arg_path: &Option<String>, |
| 20 | raw_arg: &Option<String>, |
| 21 | ) -> anyhow::Result<Option<Vec<u8>>> { |
| 22 | // TODO: It would be really nice to be able to use `blob_from_arguments(..)` here, as in dfx, to get all the nice things such as help composing the argument. |
| 23 | // First try to read the argument file, if it was provided |
| 24 | |
| 25 | let candid = arg_path |
| 26 | .as_ref() |
| 27 | .map(std::fs::read_to_string) |
| 28 | .transpose()? |
| 29 | // Otherwise use the argument from the command line |
| 30 | .or_else(|| arg_string.clone()) |
| 31 | // Parse the candid |
| 32 | .map(|arg_string| { |
| 33 | candid_parser::parse_idl_args(&arg_string) |
| 34 | .with_context(|| "Invalid Candid values".to_string())? |
| 35 | .to_bytes() |
| 36 | }) |
| 37 | .transpose()?; |
| 38 | |
| 39 | let raw_arg = raw_arg.as_ref().map(hex::decode).transpose()?; |
| 40 | let arg = candid.or(raw_arg); |
| 41 | Ok(arg) |
| 42 | } |
| 43 | |
| 44 | pub(super) fn log_hashes( |
| 45 | logger: &Logger, |
no test coverage detected