Adds --theme-only option which will only copy the theme folder

This commit is contained in:
Sathis Kumar 2021-06-22 19:31:01 +05:30
parent 4d2dc6f482
commit de38a3e026
3 changed files with 13 additions and 2 deletions

View File

@ -52,3 +52,8 @@ directory called `theme` in your source directory so that you can modify it.
The theme is selectively overwritten, this means that if you don't want to The theme is selectively overwritten, this means that if you don't want to
overwrite a specific file, just delete it and the default file will be used. overwrite a specific file, just delete it and the default file will be used.
#### --theme-only
Optionally you can use `--theme-only` flag, only the default theme will be copied into a
directory called `theme` in your source directory so that you can modify it.

View File

@ -106,7 +106,9 @@ impl BookBuilder {
Ok(()) Ok(())
} }
fn copy_across_theme(&self) -> Result<()> { /// Copies the theme to the generated book (so users can tweak
/// it)?
pub fn copy_across_theme(&self) -> Result<()> {
debug!("Copying theme"); debug!("Copying theme");
let html_config = self.config.html_config().unwrap_or_default(); let html_config = self.config.html_config().unwrap_or_default();

View File

@ -17,6 +17,7 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
(Defaults to the Current Directory when omitted)'", (Defaults to the Current Directory when omitted)'",
) )
.arg_from_usage("--theme 'Copies the default theme into your source folder'") .arg_from_usage("--theme 'Copies the default theme into your source folder'")
.arg_from_usage("--theme-only 'Copies only the default theme into your source folder'")
.arg_from_usage("--force 'Skips confirmation prompts'") .arg_from_usage("--force 'Skips confirmation prompts'")
} }
@ -27,7 +28,10 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
let mut config = config::Config::default(); let mut config = config::Config::default();
// If flag `--theme` is present, copy theme to src // If flag `--theme` is present, copy theme to src
if args.is_present("theme") { if args.is_present("theme-only") {
builder.copy_across_theme();
return Ok(());
} else if args.is_present("theme") {
let theme_dir = book_dir.join("theme"); let theme_dir = book_dir.join("theme");
println!(); println!();
println!("Copying the default theme to {}", theme_dir.display()); println!("Copying the default theme to {}", theme_dir.display());