diff --git a/crates/cuddle-please/src/cliff/mod.rs b/crates/cuddle-please/src/cliff/mod.rs index d7d9038..4aad1b3 100644 --- a/crates/cuddle-please/src/cliff/mod.rs +++ b/crates/cuddle-please/src/cliff/mod.rs @@ -135,24 +135,18 @@ impl ChangeLog<'_> { .context("cannot convert bytes to string (contains non utf-8 char indices)") } - fn default_config<'a>(&self) -> Config { + fn default_config(&self) -> Config { let config = Config { - changelog: default_changelog_config( - None, - self.release_link.as_deref(), - ), + changelog: default_changelog_config(None, self.release_link.as_deref()), git: default_git_config(), }; config } - fn default_config_with_header<'a>(&self, header: Option) -> Config { + fn default_config_with_header(&self, header: Option) -> Config { let config = Config { - changelog: default_changelog_config( - header, - self.release_link.as_deref(), - ), + changelog: default_changelog_config(header, self.release_link.as_deref()), git: default_git_config(), }; @@ -219,9 +213,9 @@ fn default_changelog_config(header: Option, release_link: Option<&str>) } fn default_changelog_body_config(release_link: Option<&str>) -> String { - const pre: &str = r#" + const PRE: &str = r#" ## [{{ version | trim_start_matches(pat="v") }}]"#; - const post: &str = r#" - {{ timestamp | date(format="%Y-%m-%d") }} + const POST: &str = r#" - {{ timestamp | date(format="%Y-%m-%d") }} {% for group, commits in commits | group_by(attribute="group") %} ### {{ group | upper_first }} {% for commit in commits %} @@ -234,8 +228,8 @@ fn default_changelog_body_config(release_link: Option<&str>) -> String { {% endfor %}"#; match release_link { - Some(link) => format!("{}{}{}", pre, link, post), - None => format!("{}{}", pre, post), + Some(link) => format!("{}{}{}", PRE, link, POST), + None => format!("{}{}", PRE, POST), } } diff --git a/crates/cuddle-please/src/command.rs b/crates/cuddle-please/src/command.rs index e4b9d34..adf59e0 100644 --- a/crates/cuddle-please/src/command.rs +++ b/crates/cuddle-please/src/command.rs @@ -19,6 +19,8 @@ use crate::{ versioning::{next_version::NextVersion, semver::get_most_significant_version}, }; +type StdinFn = Option anyhow::Result + Send + Sync + 'static>>>; + #[derive(Parser)] #[command(author, version, about, long_about = None)] pub struct Command { @@ -32,7 +34,7 @@ pub struct Command { ui: DynUi, #[clap(skip)] - stdin: Option anyhow::Result + Send + Sync + 'static>>>, + stdin: StdinFn, } #[derive(Args)] @@ -96,6 +98,12 @@ config-stdin will consume stdin until the channel is closed via. EOF" config_stdin: bool, } +impl Default for Command { + fn default() -> Self { + Self::new() + } +} + impl Command { pub fn new() -> Self { let args = std::env::args(); @@ -256,10 +264,8 @@ impl Command { self.ui.write_str_ln(&format!("OK: {}", stdout)); } Err(e) => { - self.ui.write_str_ln(&format!( - "WARNING: git is not installed: {}", - e - )); + self.ui + .write_str_ln(&format!("WARNING: git is not installed: {}", e)); } } } @@ -395,7 +401,7 @@ impl Command { Ok(()) } - fn get_git(&self, current_dir: &PathBuf) -> anyhow::Result { + fn get_git(&self, current_dir: &Path) -> anyhow::Result { if self.global.no_vcs { Ok(VcsClient::new_noop()) } else { @@ -490,8 +496,7 @@ pub struct PleaseSettingsConfig { pub api_url: Option, } -#[derive(Debug, Clone, Serialize, Deserialize)] -#[derive(Default)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct PleaseConfig { pub project: Option, pub settings: Option, @@ -507,8 +512,6 @@ impl PleaseConfig { } } - - #[derive(Debug, Clone, Serialize, Deserialize)] struct CuddleEmbeddedPleaseConfig { please: PleaseConfig, @@ -558,7 +561,7 @@ fn get_config(current_dir: &Path, stdin: Option) -> anyhow::Result(current_cuddle_path: PathBuf) -> Option +fn get_config_from_file(current_cuddle_path: PathBuf) -> Option where T: DeserializeOwned, T: Into,