parse for stdin

This commit is contained in:
Aiden McClelland
2021-05-21 13:36:01 -06:00
parent f5217d0e53
commit 33d7d095e3

View File

@@ -497,8 +497,14 @@ fn cli_handler(
let arg_name = LitStr::new(&name.to_string(), name.span()); let arg_name = LitStr::new(&name.to_string(), name.span());
let field_name = Ident::new(&format!("arg_{}", name), name.span()); let field_name = Ident::new(&format!("arg_{}", name), name.span());
if arg.stdin.is_some() { if arg.stdin.is_some() {
quote! { if let Some(parse) = &arg.parse {
#field_name: rpc_toolkit_prelude::default_stdin_parser(&mut std::io::stdin(), matches)?, quote! {
#field_name: #parse(&mut std::io::stdin(), matches)?,
}
} else {
quote! {
#field_name: rpc_toolkit_prelude::default_stdin_parser(&mut std::io::stdin(), matches)?,
}
} }
} else if arg.check_is_present { } else if arg.check_is_present {
quote! { quote! {