diff --git a/src/app/config/arguments.rs b/src/app/config/arguments.rs index 617a218..e892b06 100644 --- a/src/app/config/arguments.rs +++ b/src/app/config/arguments.rs @@ -22,6 +22,11 @@ pub struct Args { /// The directory where the documentation will be built #[arg(short, long, global = true)] pub output_dir: Option, + + /// 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 diff --git a/src/app/config/config.rs b/src/app/config/config.rs index e8f5288..ff54f94 100644 --- a/src/app/config/config.rs +++ b/src/app/config/config.rs @@ -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, } }