Skip to content

Commit

Permalink
New default: No comments
Browse files Browse the repository at this point in the history
  • Loading branch information
msuchane committed Mar 22, 2023
1 parent 11c967a commit 0529e12
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
11 changes: 9 additions & 2 deletions src/cmd_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,17 @@ pub struct Cli {

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

/// Generate the file with explanatory comments
#[bpaf(short('M'), long)]
pub comments: bool,

/// Generate the file without any example, placeholder content
#[bpaf(short('E'), long, long("expert-mode"))]
pub no_examples: bool,
Expand Down
20 changes: 14 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Options {
// Comments and prefixes are enabled (true) by default unless you disable them
// on the command line. If the no-comments or no-prefixes option is passed,
// the feature is disabled, so the option is set to false.
comments: !cli.common_options.no_comments,
comments: cli.common_options.comments,
file_prefixes: !cli.common_options.no_file_prefixes,
anchor_prefixes: cli.common_options.anchor_prefixes,
examples: !cli.common_options.no_examples,
Expand Down Expand Up @@ -102,6 +102,19 @@ pub fn run(options: &Options, cli: &Cli) -> Result<()> {

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

// Report any deprecated options.
if !cli.action.validate.is_empty() {
log::warn!("The validation feature is deprecated and will be removed in a later version.\n\
Please switch to the `enki` validation tool: <https://github.com/Levi-Leah/enki/>.");
}
if cli.common_options.no_comments {
log::warn!(
"The --no-comments (-C) option is deprecated and has no effect anymore.\n\
By default, generated modules do not contain any comments.\n\
If you want to include comments, use the --comments (-M) option."
);
}

// Attach titles from the CLI to content types.
let content_types = [
(ContentType::Assembly, &cli.action.assembly),
Expand Down Expand Up @@ -152,11 +165,6 @@ pub fn run(options: &Options, cli: &Cli) -> Result<()> {
populated.write_file(options)?;
}

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

0 comments on commit 0529e12

Please sign in to comment.