From de38a3e026014ff19556dae443282935b83e1636 Mon Sep 17 00:00:00 2001 From: Sathis Kumar Date: Tue, 22 Jun 2021 19:31:01 +0530 Subject: [PATCH] Adds --theme-only option which will only copy the theme folder --- guide/src/cli/init.md | 5 +++++ src/book/init.rs | 4 +++- src/cmd/init.rs | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/guide/src/cli/init.md b/guide/src/cli/init.md index a0a407c5..d3b82cc7 100644 --- a/guide/src/cli/init.md +++ b/guide/src/cli/init.md @@ -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 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. diff --git a/src/book/init.rs b/src/book/init.rs index 264c113d..d026fcf9 100644 --- a/src/book/init.rs +++ b/src/book/init.rs @@ -106,7 +106,9 @@ impl BookBuilder { 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"); let html_config = self.config.html_config().unwrap_or_default(); diff --git a/src/cmd/init.rs b/src/cmd/init.rs index cccc1671..62ce971c 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -17,6 +17,7 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> { (Defaults to the Current Directory when omitted)'", ) .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'") } @@ -27,7 +28,10 @@ pub fn execute(args: &ArgMatches) -> Result<()> { let mut config = config::Config::default(); // 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"); println!(); println!("Copying the default theme to {}", theme_dir.display());