Skip to content

Commit

Permalink
Synchronize the default options with CLI args; #20
Browse files Browse the repository at this point in the history
  • Loading branch information
msuchane committed Feb 27, 2024
1 parent 738033b commit 698fba1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/cmd_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use bpaf::Bpaf;
use serde::{Serialize, Deserialize};

/// Generate pre-populated module files formatted with AsciiDoc that are used in Red Hat and Fedora documentation.
#[derive(Clone, Debug, Bpaf)]
#[derive(Clone, Debug, Bpaf, Default)]
#[bpaf(options, version)]
pub struct Cli {
#[bpaf(
Expand All @@ -40,7 +40,7 @@ pub struct Cli {
pub common_options: CommonOptions,
}

#[derive(Clone, Debug, Bpaf)]
#[derive(Clone, Debug, Bpaf, Default)]
pub struct CommonOptions {
/// Add module type prefixes (such as `proc_`) in AsciiDoc anchors
#[bpaf(short('A'), long)]
Expand Down Expand Up @@ -69,7 +69,7 @@ pub struct CommonOptions {
pub comments: Comments,
}

#[derive(Clone, Debug, Bpaf)]
#[derive(Clone, Debug, Bpaf, Default)]
pub struct Action {
/// Create an assembly file
#[bpaf(short, long, argument("TITLE"))]
Expand Down Expand Up @@ -146,5 +146,7 @@ const SOME_FILES: &str = "Specify at least one file to generate or validate.";
/// Get command-line arguments as the `Cli` struct.
#[must_use]
pub fn get_args() -> Cli {
let def = Cli::default();
println!("default args: {:#?}", def);
cli().run()
}
13 changes: 4 additions & 9 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,10 @@ impl Options {

impl Default for Options {
fn default() -> Self {
Self {
comments: false,
file_prefixes: true,
anchor_prefixes: false,
examples: true,
target_dir: PathBuf::from("."),
simplified: false,
verbosity: Verbosity::Default,
}
// Synchronize the `Options` defaults with the default command-line arguments.
let default_cli_args = Cli::default();

Self::new(&default_cli_args)
}
}

Expand Down

0 comments on commit 698fba1

Please sign in to comment.