fix: add validation when passing inline-images flag
This commit is contained in:
parent
40cf5b06c9
commit
9c2232e37f
2 changed files with 14 additions and 2 deletions
12
src/cli.rs
12
src/cli.rs
|
@ -164,7 +164,17 @@ impl<'a> TryFrom<ArgMatches<'a>> for AppConfig {
|
||||||
ExportType::EPUB
|
ExportType::EPUB
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.is_inlining_images(arg_matches.is_present("inline-images"))
|
.is_inlining_images(
|
||||||
|
(if arg_matches.is_present("inline-images") {
|
||||||
|
if arg_matches.value_of("export") == Some("html") {
|
||||||
|
Ok(true)
|
||||||
|
} else {
|
||||||
|
Err(Error::WrongExportInliningImages)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Ok(false)
|
||||||
|
})?,
|
||||||
|
)
|
||||||
.try_init()
|
.try_init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,6 +156,8 @@ pub enum CliError<BuilderError: Debug + Display> {
|
||||||
OutputDirectoryNotExists,
|
OutputDirectoryNotExists,
|
||||||
#[error("Unable to start logger!\n{0}")]
|
#[error("Unable to start logger!\n{0}")]
|
||||||
LogError(#[from] LogError),
|
LogError(#[from] LogError),
|
||||||
#[error("The --inline-toc can only be used exporting to epub")]
|
#[error("The --inline-toc flag can only be used when exporting to epub")]
|
||||||
WrongExportInliningToC,
|
WrongExportInliningToC,
|
||||||
|
#[error("The --inline-images flag can only be used when exporting to html")]
|
||||||
|
WrongExportInliningImages,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue