mirror of
https://github.com/lise-henry/crowbook
synced 2024-09-30 04:51:21 +02:00
Add option --single to the binary
This option allows Crowbook to parse a single MarkDown file, defaulting to hide the chapters' headings. This should allow to get ride of `.book` file for short stories. Resolves: #2, #3
This commit is contained in:
parent
61f4dabff5
commit
7be4af4264
@ -86,6 +86,7 @@ pub fn create_matches<'a>() -> ArgMatches<'a> {
|
||||
.setting(AppSettings::UnifiedHelpMessage)
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.about("Render a markdown book in Epub, PDF or HTML.")
|
||||
.arg_from_usage("-s, --single 'Create a book from a single MarkDown file'")
|
||||
.arg_from_usage("-v, --verbose 'Print warnings in parsing/rendering'")
|
||||
.arg_from_usage("-d, --debug 'Print additional information")
|
||||
.arg_from_usage("--create [FILES]... 'Creates a new book with existing markdown files.'")
|
||||
@ -93,10 +94,10 @@ pub fn create_matches<'a>() -> ArgMatches<'a> {
|
||||
.requires("to"))
|
||||
.arg(Arg::from_usage("-t, --to [FORMAT] 'Generate specific format'")
|
||||
.possible_values(&["epub", "pdf", "html", "tex", "odt"]))
|
||||
.arg(Arg::from_usage("-s, --set [KEY_VALUES] 'Sets a list of book options'")
|
||||
.arg(Arg::from_usage("--set [KEY_VALUES] 'Sets a list of book options'")
|
||||
.min_values(2))
|
||||
.arg(Arg::from_usage("-l --list-options 'Lists all possible options"))
|
||||
.arg_from_usage("--list-options-md 'List all options, formatted in Markdown")
|
||||
.arg_from_usage("--list-options-md 'List all options, formatted in Markdown.'")
|
||||
.arg_from_usage("--print-template [TEMPLATE] 'Displays the default value of a template.'")
|
||||
.arg(Arg::with_name("BOOK")
|
||||
.index(1)
|
||||
|
@ -137,7 +137,14 @@ fn main() {
|
||||
} else {
|
||||
InfoLevel::Info
|
||||
};
|
||||
match Book::new_from_file(s, verbosity) {
|
||||
|
||||
let book_res = if matches.is_present("single") {
|
||||
Book::new_from_markdown_file(s, verbosity)
|
||||
} else {
|
||||
Book::new_from_file(s, verbosity)
|
||||
};
|
||||
|
||||
match book_res {
|
||||
Err(err) => print_error(&format!("{}", err)),
|
||||
Ok(mut book) => {
|
||||
set_book_options(&mut book, &matches);
|
||||
|
Loading…
Reference in New Issue
Block a user