diff --git a/src/cmd_line.rs b/src/cmd_line.rs index f78d5fa..a643695 100644 --- a/src/cmd_line.rs +++ b/src/cmd_line.rs @@ -46,21 +46,10 @@ pub struct CommonOptions { #[bpaf(short('A'), long)] pub anchor_prefixes: bool, - /// 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 without any example, placeholder content #[bpaf(short('E'), long, long("expert-mode"))] pub no_examples: bool, - /// Generate the file with explanatory comments - #[bpaf(short('M'), long)] - pub comments: bool, - /// Do not use module type prefixes (such as `proc_`) in file names #[bpaf(short('P'), long, long("no-prefixes"))] pub no_file_prefixes: bool, @@ -73,8 +62,11 @@ pub struct CommonOptions { #[bpaf(short('T'), long, argument("DIRECTORY"), fallback(".".into()))] pub target_dir: PathBuf, - #[bpaf(external, fallback(Verbosity::Default))] + #[bpaf(external, fallback(Verbosity::default()))] pub verbosity: Verbosity, + + #[bpaf(external, fallback(Comments::default()))] + pub comments: Comments, } #[derive(Clone, Debug, Bpaf)] @@ -125,6 +117,18 @@ pub enum Verbosity { Default, } +#[derive(Clone, Copy, Debug, Bpaf, Serialize, Deserialize, Default, PartialEq)] +pub enum Comments { + /// Generate the file without any comments. + /// This option is now the default. + #[default] + #[bpaf(short('C'), long)] + NoComments, + /// Generate the file with explanatory comments + #[bpaf(short('M'), long)] + Comments, +} + /// Check that the current command generates or validates at least one file. fn at_least_one_file(action: &Action) -> bool { !action.assembly.is_empty() diff --git a/src/config.rs b/src/config.rs index 07fa916..7b12989 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,7 +4,7 @@ use directories::ProjectDirs; use figment::{Figment, providers::{Format, Toml, Serialized}}; use serde::{Serialize, Deserialize}; -use crate::cmd_line::{Cli, Verbosity}; +use crate::cmd_line::{Cli, Comments, Verbosity}; const PKG_NAME: &str = env!("CARGO_PKG_NAME"); @@ -29,7 +29,10 @@ 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.comments, + comments: match cli.common_options.comments { + Comments::Comments => true, + Comments::NoComments => false, + }, file_prefixes: !cli.common_options.no_file_prefixes, anchor_prefixes: cli.common_options.anchor_prefixes, examples: !cli.common_options.no_examples, diff --git a/src/lib.rs b/src/lib.rs index 29084c2..f71a236 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,13 +63,6 @@ pub fn run(options: &Options, cli: &Cli) -> Result<()> { log::warn!("The validation feature has been removed. \ Please switch to the Enki validation tool: ."); } - 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 = [