Skip to content

Commit

Permalink
Override for the simplified option; #20
Browse files Browse the repository at this point in the history
  • Loading branch information
msuchane committed Feb 28, 2024
1 parent 022c5cf commit 026a99e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
27 changes: 18 additions & 9 deletions src/cmd_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,18 @@ pub struct CommonOptions {
#[bpaf(short('P'), long, long("no-prefixes"))]
pub no_file_prefixes: bool,

/// Generate the file without conditionals for the Red Hat documentation pipeline. Suitable for upstream.
#[bpaf(short('S'), long)]
pub simplified: bool,

/// Save the generated files in this directory
#[bpaf(short('T'), long, argument("DIRECTORY"), fallback(".".into()))]
pub target_dir: PathBuf,

#[bpaf(external, fallback(Verbosity::default()))]
pub verbosity: Verbosity,

#[bpaf(external, fallback(Comments::default()))]
pub comments: Comments,

#[bpaf(external, fallback(Simplified::default()))]
pub simplified: Simplified,

#[bpaf(external, fallback(Verbosity::default()))]
pub verbosity: Verbosity,
}

#[derive(Clone, Debug, Bpaf, Default)]
Expand Down Expand Up @@ -119,8 +118,7 @@ pub enum Verbosity {

#[derive(Clone, Copy, Debug, Bpaf, Serialize, Deserialize, Default, PartialEq)]
pub enum Comments {
/// Generate the file without any comments.
/// This option is now the default.
/// Generate the file without any comments. (Default)
#[default]
#[bpaf(short('C'), long)]
NoComments,
Expand All @@ -129,6 +127,17 @@ pub enum Comments {
Comments,
}

#[derive(Clone, Copy, Debug, Bpaf, Serialize, Deserialize, Default, PartialEq)]
pub enum Simplified {
/// Generate the file without conditionals for the Red Hat documentation pipeline. Suitable for upstream.
#[bpaf(short('S'), long)]
Simplified,
/// Generate the file with conditionals for the Red Hat documentation pipeline. (Default)
#[default]
#[bpaf(long)]
NotSimplified,
}

/// Check that the current command generates or validates at least one file.
fn at_least_one_file(action: &Action) -> bool {
!action.assembly.is_empty()
Expand Down
7 changes: 5 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use figment::{
};
use serde::{Deserialize, Serialize};

use crate::cmd_line::{Cli, Comments, Verbosity};
use crate::cmd_line::{Cli, Comments, Simplified, Verbosity};

const PKG_NAME: &str = env!("CARGO_PKG_NAME");

Expand Down Expand Up @@ -65,7 +65,10 @@ impl Options {
examples: !cli.common_options.no_examples,
// Set the target directory as specified or fall back on the current directory
target_dir: cli.common_options.target_dir.clone(),
simplified: cli.common_options.simplified,
simplified: match cli.common_options.simplified {
Simplified::Simplified => true,
Simplified::NotSimplified => false,
},
verbosity: cli.common_options.verbosity,
}
}
Expand Down

0 comments on commit 026a99e

Please sign in to comment.