remove message from changelog, add skeletons for release and publish
cargo devel CI / cargo CI (push) Successful in 4m15s Details

This commit is contained in:
Christoph J. Scherr 2024-01-27 23:46:00 +01:00
parent e62a0f3534
commit 0c603f9e56
Signed by: PlexSheep
GPG Key ID: 7CDD0B14851A08EF
4 changed files with 21 additions and 14 deletions

View File

@ -8,7 +8,6 @@ use crate::{
/// Represents a changelog that is currently under construction. /// Represents a changelog that is currently under construction.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Changelog { pub struct Changelog {
message: Option<String>,
git_log: Option<String>, git_log: Option<String>,
} }
@ -17,14 +16,8 @@ impl Changelog {
if !cfg.yaml.changelog.enable { if !cfg.yaml.changelog.enable {
return Err(ConfigError::IsDisabledButUsed("changelog").into()); return Err(ConfigError::IsDisabledButUsed("changelog").into());
} }
let message: Option<String> = 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)?; let git_log = Self::make_git_log(cfg)?;
Ok(Changelog { message, git_log }) Ok(Changelog { git_log })
} }
fn make_git_log(cfg: &Config) -> Result<Option<String>> { fn make_git_log(cfg: &Config) -> Result<Option<String>> {
@ -39,9 +32,6 @@ impl Display for Changelog {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut full: String = String::new(); let mut full: String = String::new();
full += "Changelog"; full += "Changelog";
if self.message.is_some() {
full += format!("\n\n{}", self.message.clone().unwrap()).as_str();
}
if self.git_log.is_some() { if self.git_log.is_some() {
full += format!("\n\n{}", self.git_log.clone().unwrap()).as_str(); full += format!("\n\n{}", self.git_log.clone().unwrap()).as_str();
} }

View File

@ -37,7 +37,8 @@ pub struct Cli {
#[derive(Debug, Clone, Subcommand)] #[derive(Debug, Clone, Subcommand)]
pub enum Commands { pub enum Commands {
Changelog { Changelog {},
Release {
// FIXME: allow taking a message like this: // FIXME: allow taking a message like this:
// `autocrate changelog -m arg1 arg2 arg3` // `autocrate changelog -m arg1 arg2 arg3`
// -> msg="arg1 arg2 arg3" // -> msg="arg1 arg2 arg3"
@ -48,6 +49,14 @@ pub enum Commands {
// TODO: // TODO:
// Perhaps open the $EDITOR of the user if // Perhaps open the $EDITOR of the user if
// no message is provided, like git does // 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<Vec<String>>,
},
Publish {
// see Commands::Release { message }
#[arg(short, long)] #[arg(short, long)]
message: Option<Vec<String>>, message: Option<Vec<String>>,
}, },
@ -60,6 +69,8 @@ impl Display for Commands {
"{}", "{}",
match self { match self {
Self::Changelog { .. } => "Changelog", Self::Changelog { .. } => "Changelog",
Self::Release { .. } => "Release",
Self::Publish { .. } => "Publish",
} }
) )
} }

View File

@ -28,8 +28,8 @@ impl YamlConfigSection for Changelog {
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
pub struct UseCargo { pub struct UseCargo {
publish: bool, pub publish: bool,
registries: Vec<String>, pub registries: Vec<String>,
} }
impl YamlConfigSection for UseCargo { impl YamlConfigSection for UseCargo {
fn check(&self) -> Result<()> { fn check(&self) -> Result<()> {

View File

@ -16,5 +16,11 @@ fn main() -> Result<()> {
println!("{}", Changelog::build(&cfg)?.to_string()); println!("{}", Changelog::build(&cfg)?.to_string());
Ok(()) Ok(())
} }
Commands::Release { .. } => {
todo!()
}
Commands::Publish { .. } => {
todo!()
}
} }
} }