made offline-reveal a global argument (easier for me)*

This commit is contained in:
2025-11-13 09:35:36 +01:00
parent 3ae1b2cc6e
commit 1f2d9e4363
2 changed files with 10 additions and 16 deletions

View File

@@ -22,6 +22,11 @@ pub struct Args {
/// The directory where the documentation will be built
#[arg(short, long, global = true)]
pub output_dir: Option<String>,
/// When set to true, docki will download revealjs before building the documentation.
/// Otherwise it will use the cdn for revealjs
#[arg(long, global = true)]
pub offline_reveal: bool,
}
#[derive(Subcommand)]
@@ -34,12 +39,7 @@ pub enum ShellArg {
#[derive(Subcommand)]
pub enum CommandArg {
/// Builds the documentation into the specified output_dir
Build {
/// When set to true, docki will download revealjs before building the documentation.
/// Otherwise it will use the cdn for revealjs
#[arg(long)]
offline_reveal: bool,
},
Build,
/// Checks if everything required for docki is installed
Health,
/// Deprecated: Helper command for installing asciidoctor-reveal-js

View File

@@ -8,7 +8,7 @@ pub struct Config {
pub port: u16,
pub input_dir: String,
pub offline_reveal: bool,
pub output_dir: String
pub output_dir: String,
}
impl Config {
@@ -26,14 +26,8 @@ impl Config {
_ => self.port,
},
input_dir: args.input_dir.clone().unwrap_or(self.input_dir),
output_dir: args.output_dir.clone().unwrap_or(self.output_dir),
offline_reveal: {
if let CommandArg::Build { offline_reveal } = args.command {
offline_reveal
} else {
self.offline_reveal
}
},
output_dir: args.output_dir.clone().unwrap_or(self.output_dir),
offline_reveal: args.offline_reveal || self.offline_reveal,
}
}
}
@@ -43,7 +37,7 @@ impl Default for Config {
Self {
port: 8080,
input_dir: "./docs".to_string(),
output_dir: "./dist".to_string(),
output_dir: "./dist".to_string(),
offline_reveal: false,
}
}