From 0c603f9e56de5d32b7733b0aa79fd4a07279cf34 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sat, 27 Jan 2024 23:46:00 +0100 Subject: [PATCH] remove message from changelog, add skeletons for release and publish --- src/changelog/mod.rs | 12 +----------- src/config/cli.rs | 13 ++++++++++++- src/config/mod.rs | 4 ++-- src/main.rs | 6 ++++++ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/changelog/mod.rs b/src/changelog/mod.rs index 3cd41a0..3381621 100644 --- a/src/changelog/mod.rs +++ b/src/changelog/mod.rs @@ -8,7 +8,6 @@ use crate::{ /// Represents a changelog that is currently under construction. #[derive(Clone, Debug)] pub struct Changelog { - message: Option, git_log: Option, } @@ -17,14 +16,8 @@ impl Changelog { if !cfg.yaml.changelog.enable { return Err(ConfigError::IsDisabledButUsed("changelog").into()); } - let message: Option = match cfg.cli.command.clone() { - Commands::Changelog { message } => match message { - Some(msgs) => Some(msgs.concat()), - None => None, - }, - }; let git_log = Self::make_git_log(cfg)?; - Ok(Changelog { message, git_log }) + Ok(Changelog { git_log }) } fn make_git_log(cfg: &Config) -> Result> { @@ -39,9 +32,6 @@ impl Display for Changelog { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut full: String = String::new(); full += "Changelog"; - if self.message.is_some() { - full += format!("\n\n{}", self.message.clone().unwrap()).as_str(); - } if self.git_log.is_some() { full += format!("\n\n{}", self.git_log.clone().unwrap()).as_str(); } diff --git a/src/config/cli.rs b/src/config/cli.rs index a0c81f2..5751c65 100644 --- a/src/config/cli.rs +++ b/src/config/cli.rs @@ -37,7 +37,8 @@ pub struct Cli { #[derive(Debug, Clone, Subcommand)] pub enum Commands { - Changelog { + Changelog {}, + Release { // FIXME: allow taking a message like this: // `autocrate changelog -m arg1 arg2 arg3` // -> msg="arg1 arg2 arg3" @@ -48,6 +49,14 @@ pub enum Commands { // TODO: // Perhaps open the $EDITOR of the user if // no message is provided, like git does + // + // TODO: + // find a way to make this a global option but only usable with specific subcommands + #[arg(short, long)] + message: Option>, + }, + Publish { + // see Commands::Release { message } #[arg(short, long)] message: Option>, }, @@ -60,6 +69,8 @@ impl Display for Commands { "{}", match self { Self::Changelog { .. } => "Changelog", + Self::Release { .. } => "Release", + Self::Publish { .. } => "Publish", } ) } diff --git a/src/config/mod.rs b/src/config/mod.rs index 1695c33..90b08a9 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -28,8 +28,8 @@ impl YamlConfigSection for Changelog { #[derive(Debug, Clone, Deserialize)] pub struct UseCargo { - publish: bool, - registries: Vec, + pub publish: bool, + pub registries: Vec, } impl YamlConfigSection for UseCargo { fn check(&self) -> Result<()> { diff --git a/src/main.rs b/src/main.rs index c6074d4..7e45f2b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,5 +16,11 @@ fn main() -> Result<()> { println!("{}", Changelog::build(&cfg)?.to_string()); Ok(()) } + Commands::Release { .. } => { + todo!() + } + Commands::Publish { .. } => { + todo!() + } } }