Skip to content

Commit 0529e12

Browse files
author
Marek Suchánek
committed
New default: No comments
1 parent 11c967a commit 0529e12

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/cmd_line.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@ pub struct Cli {
4141

4242
#[derive(Clone, Debug, Bpaf)]
4343
pub struct CommonOptions {
44-
/// Generate the file without any comments
45-
#[bpaf(short('C'), long)]
44+
/// Generate the file without any comments.
45+
/// This option is now the default.
46+
/// The option is hidden, has no effect, and exists only for compatibility
47+
/// with previous releases.
48+
#[bpaf(short('C'), long, hide)]
4649
pub no_comments: bool,
4750

51+
/// Generate the file with explanatory comments
52+
#[bpaf(short('M'), long)]
53+
pub comments: bool,
54+
4855
/// Generate the file without any example, placeholder content
4956
#[bpaf(short('E'), long, long("expert-mode"))]
5057
pub no_examples: bool,

src/lib.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Options {
7272
// Comments and prefixes are enabled (true) by default unless you disable them
7373
// on the command line. If the no-comments or no-prefixes option is passed,
7474
// the feature is disabled, so the option is set to false.
75-
comments: !cli.common_options.no_comments,
75+
comments: cli.common_options.comments,
7676
file_prefixes: !cli.common_options.no_file_prefixes,
7777
anchor_prefixes: cli.common_options.anchor_prefixes,
7878
examples: !cli.common_options.no_examples,
@@ -102,6 +102,19 @@ pub fn run(options: &Options, cli: &Cli) -> Result<()> {
102102

103103
log::debug!("Active options:\n{:#?}", &options);
104104

105+
// Report any deprecated options.
106+
if !cli.action.validate.is_empty() {
107+
log::warn!("The validation feature is deprecated and will be removed in a later version.\n\
108+
Please switch to the `enki` validation tool: <https://github.com/Levi-Leah/enki/>.");
109+
}
110+
if cli.common_options.no_comments {
111+
log::warn!(
112+
"The --no-comments (-C) option is deprecated and has no effect anymore.\n\
113+
By default, generated modules do not contain any comments.\n\
114+
If you want to include comments, use the --comments (-M) option."
115+
);
116+
}
117+
105118
// Attach titles from the CLI to content types.
106119
let content_types = [
107120
(ContentType::Assembly, &cli.action.assembly),
@@ -152,11 +165,6 @@ pub fn run(options: &Options, cli: &Cli) -> Result<()> {
152165
populated.write_file(options)?;
153166
}
154167

155-
// If the validate option is active, report the deprecation.
156-
if !cli.action.validate.is_empty() {
157-
log::warn!("The validation feature is deprecated and will be removed in a later version. \
158-
Please switch to the `enki` validation tool: <https://github.com/Levi-Leah/enki/>.");
159-
}
160168
// Validate all file names specified on the command line
161169
for file in &cli.action.validate {
162170
validation::validate(file).wrap_err_with(|| eyre!("Failed to validate file {:?}", file))?;

0 commit comments

Comments
 (0)