panic if pos arg not found or help is missing
@@ -754,9 +754,13 @@ fn generate_manpages(mut app: clap::Command, rest_args: Vec<String>) -> Error {
}
}
let mut body = vec![];
- if let Some(help) = opt.get_long_help().or_else(|| opt.get_help()) {
+
+ let help = opt
+ .get_long_help()
+ .or_else(|| opt.get_help())
+ .expect("option is missing help");
body.push(roman(help));
- }
+
if let Some(possible_values) = opt.get_possible_values() {
if !opt.is_hide_possible_values_set() {
let possible_values_text = format!(
@@ -775,7 +779,15 @@ fn generate_manpages(mut app: clap::Command, rest_args: Vec<String>) -> Error {
roff.text(body);
}
- if let Some(opt) = items.iter().find(|opt| opt.get_id() == "raw-method-or-url") {
+ let method_url = items
+ .iter()
+ .find(|opt| opt.get_id() == "raw-method-or-url")
+ .unwrap();
+ let method_url_help = method_url
+ .get_long_help()
+ .or_else(|| method_url.get_help())
+ .expect("[method] url is missing help");
+
roff.control("TP", []);
roff.text(vec![
roman("["),
@@ -783,15 +795,19 @@ fn generate_manpages(mut app: clap::Command, rest_args: Vec<String>) -> Error {
roman("]"),
italic(" URL"),
]);
- if let Some(help) = opt.get_long_help().or_else(|| opt.get_help()) {
- roff.text(vec![roman(help)]);
- }
- }
+ roff.text(vec![roman(method_url_help)]);
+
+ let request_items = items
+ .iter()
+ .find(|opt| opt.get_id() == "raw-rest-args")
+ .unwrap();
+ let request_items_help = request_items
+ .get_long_help()
+ .or_else(|| request_items.get_help())
+ .expect("request_items is missing help");
- if let Some(opt) = items.iter().find(|opt| opt.get_id() == "raw-rest-args") {
roff.control("TP", []);
roff.text(vec![roman("["), italic("REQUEST_ITEM"), roman(" ...]")]);
- if let Some(help) = opt.get_long_help().or_else(|| opt.get_help()) {
// replace the indents in request_item help with proper roff controls
// For example:
//
@@ -826,7 +842,7 @@ fn generate_manpages(mut app: clap::Command, rest_args: Vec<String>) -> Error {
// normal help normal help
// .RE
// ```
- let lines: Vec<&str> = help.lines().collect();
+ let lines: Vec<&str> = request_items_help.lines().collect();
let mut rs = false;
for i in 0..lines.len() {
if lines[i].is_empty() {
@@ -850,8 +866,6 @@ fn generate_manpages(mut app: clap::Command, rest_args: Vec<String>) -> Error {
}
}
roff.control("RE", []);
- }
- }
let mut manpage = fs::read_to_string(format!("{}/man-template.roff", rest_args[0])).unwrap();
