Skip to content

Commit fd98329

Browse files
author
Marek Suchánek
committed
Metadata config in CLI; 45
1 parent 704d008 commit fd98329

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/cmd_line.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ pub struct CommonOptions {
5252
#[bpaf(external, optional)]
5353
pub examples: Option<Examples>,
5454

55+
#[bpaf(external, optional)]
56+
pub metadata: Option<Metadata>,
57+
5558
#[bpaf(external, optional)]
5659
pub file_prefixes: Option<FilePrefixes>,
5760

@@ -147,6 +150,17 @@ pub enum Simplified {
147150
NotSimplified,
148151
}
149152

153+
#[derive(Clone, Copy, Debug, Bpaf, Default, PartialEq)]
154+
pub enum Metadata {
155+
/// Generate the file with the metadata attributes header. (Default)
156+
#[default]
157+
#[bpaf(long)]
158+
Metadata,
159+
/// Generate the file without any example, placeholder content.
160+
#[bpaf(long)]
161+
NoMetadata,
162+
}
163+
150164
#[derive(Clone, Copy, Debug, Bpaf, Default, PartialEq)]
151165
pub enum FilePrefixes {
152166
/// Use module type prefixes (such as `proc_`) in file names. (Default)

src/config.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use figment::{
3232
use serde::{Deserialize, Serialize};
3333

3434
use crate::cmd_line::{
35-
AnchorPrefixes, Cli, Comments, Examples, FilePrefixes, Simplified, Verbosity,
35+
AnchorPrefixes, Cli, Comments, Examples, Metadata, FilePrefixes, Simplified, Verbosity,
3636
};
3737

3838
const PKG_NAME: &str = env!("CARGO_PKG_NAME");
@@ -98,6 +98,15 @@ impl Options {
9898
}
9999
None => { /* Keep the existing value. */ }
100100
}
101+
match cli.common_options.metadata {
102+
Some(Metadata::Metadata) => {
103+
self.metadata = true;
104+
}
105+
Some(Metadata::NoMetadata) => {
106+
self.metadata = false;
107+
}
108+
None => { /* Keep the existing value. */ }
109+
}
101110
match cli.common_options.simplified {
102111
Some(Simplified::Simplified) => {
103112
self.simplified = true;

0 commit comments

Comments
 (0)