@@ -20,8 +20,8 @@ pub(crate) struct Config {
20
20
impl Config {
21
21
pub(crate) fn from_args(args: Vec<String>) -> Self {
22
22
let mut opts = Options::new();
23
- opts.reqopt ("", "nodejs", "absolute path of nodejs", "PATH")
24
- .reqopt ("", "npm", "absolute path of npm", "PATH")
23
+ opts.optopt ("", "nodejs", "absolute path of nodejs", "PATH")
24
+ .optopt ("", "npm", "absolute path of npm", "PATH")
25
25
.reqopt("", "out-dir", "output path of doc compilation", "PATH")
26
26
.reqopt("", "rust-src", "root source of the rust source", "PATH")
27
27
.reqopt(
@@ -47,9 +47,18 @@ impl Config {
47
47
Err(f) => panic!("{:?}", f),
48
48
};
49
49
50
+ let Some(nodejs) = matches.opt_str("nodejs").map(PathBuf::from) else {
51
+ eprintln!("`nodejs` was not provided. If not available, please install it");
52
+ std::process::exit(1);
53
+ };
54
+ let Some(npm) = matches.opt_str("npm").map(PathBuf::from) else {
55
+ eprintln!("`npm` was not provided. If not available, please install it");
56
+ std::process::exit(1);
57
+ };
58
+
50
59
Self {
51
- nodejs: matches.opt_str("nodejs").map(PathBuf::from).expect("nodejs isn't available") ,
52
- npm: matches.opt_str("npm").map(PathBuf::from).expect("npm isn't available") ,
60
+ nodejs,
61
+ npm,
53
62
rust_src: matches.opt_str("rust-src").map(PathBuf::from).unwrap(),
54
63
out_dir: matches.opt_str("out-dir").map(PathBuf::from).unwrap(),
55
64
initial_cargo: matches.opt_str("initial-cargo").map(PathBuf::from).unwrap(),
0 commit comments