Skip to content

Commit e89e0ed

Browse files
committed
Add help option
1 parent 496263d commit e89e0ed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

xtask/src/main.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type Result<T> = std::result::Result<T, Box<dyn Error>>;
77
fn main() -> Result<()> {
88
let mut args = std::env::args().skip(1);
99
let cmd = args.next();
10+
const OPTIONS: &'static str = "linkcheck, style-check, test-all";
1011
match cmd.as_deref() {
1112
Some("test-all") => {
1213
mdbook_test()?;
@@ -18,14 +19,13 @@ fn main() -> Result<()> {
1819
}
1920
Some("linkcheck") => linkcheck(args)?,
2021
Some("style-check") => style_check()?,
22+
Some("-h" | "--help") => eprintln!("valid options: {OPTIONS}"),
2123
Some(x) => {
22-
eprintln!(
23-
"error: unknown command `{x}` (valid options: linkcheck, style-check, test-all)"
24-
);
24+
eprintln!("error: unknown command `{x}` (valid options: {OPTIONS})");
2525
exit(1);
2626
}
2727
None => {
28-
eprintln!("error: specify a command (valid options: linkcheck, style-check, test-all)");
28+
eprintln!("error: specify a command (valid options: {OPTIONS})");
2929
exit(1);
3030
}
3131
}

0 commit comments

Comments
 (0)