uucore: make help_{about,usage} fail if no text is found

This commit is contained in:
Terts Diepraam 2024-02-06 13:45:43 +01:00
parent 64cb591e3b
commit 0b89a734b6

View file

@ -63,6 +63,9 @@ pub fn help_about(input: TokenStream) -> TokenStream {
let input: Vec<TokenTree> = input.into_iter().collect();
let filename = get_argument(&input, 0, "filename");
let text: String = uuhelp_parser::parse_about(&read_help(&filename));
if text.is_empty() {
panic!("About text not found! Make sure the markdown format is correct");
}
TokenTree::Literal(Literal::string(&text)).into()
}
@ -77,6 +80,9 @@ pub fn help_usage(input: TokenStream) -> TokenStream {
let input: Vec<TokenTree> = input.into_iter().collect();
let filename = get_argument(&input, 0, "filename");
let text: String = uuhelp_parser::parse_usage(&read_help(&filename));
if text.is_empty() {
panic!("Usage text not found! Make sure the markdown format is correct");
}
TokenTree::Literal(Literal::string(&text)).into()
}