mod exec;
pub(super) use exec::run;
use super::RenderHelp;
pub struct Publish {
pub tt: PublishType,
pub devel: bool,
}
impl RenderHelp for Publish {
fn render_help(code: i32) -> ! {
eprintln!("Publish the selected set of crates");
eprintln!("Usage: cargo ws2 <...> publish [=]<level> [OPTIONS]");
eprintln!("");
eprintln!("When prepending `=` to the level, bump crates in sync\n");
eprintln!("Available levels:\n");
eprintln!(" - major: Bump major version (1.0.0 -> 2.0.0)");
eprintln!(" - minor: Bump minor version (0.5.0 -> 0.6.0)");
eprintln!(" - patch: Bump patch version (0.5.0 -> 0.5.1)");
eprintln!("");
eprintln!("Available options:\n");
eprintln!(" - alpha: Create a new alpha (append `-alpha.X`)");
eprintln!(" - beta: Create a new beta (append `-beta.X`)");
eprintln!(" - rc: Create a new rc (append `-rc.X`)");
eprintln!(" - devel: Tag next version as -devel");
std::process::exit(code)
}
}
pub enum PublishType {
Fixed(String),
Major(PublishMod),
Minor(PublishMod),
Patch(PublishMod),
}
impl PublishType {
pub(crate) fn _mod(&self) -> Option<&PublishMod> {
match self {
Self::Major(ref m) => Some(m),
Self::Minor(ref m) => Some(m),
Self::Patch(ref m) => Some(m),
Self::Fixed(_) => None,
}
.and_then(|_mod| match _mod {
PublishMod::None => None,
other => Some(other),
})
}
}
pub enum PublishMod {
None,
Alpha,
Beta,
Rc,
}
pub mod versions {
use super::{PublishMod, PublishType};
pub fn major(_mod: PublishMod) -> PublishType {
PublishType::Major(_mod)
}
pub fn minor(_mod: PublishMod) -> PublishType {
PublishType::Minor(_mod)
}
pub fn patch(_mod: PublishMod) -> PublishType {
PublishType::Patch(_mod)
}
pub fn mod_none() -> PublishMod {
PublishMod::None
}
pub fn mod_alpha() -> PublishMod {
PublishMod::Alpha
}
pub fn mod_beta() -> PublishMod {
PublishMod::Beta
}
pub fn mod_rc() -> PublishMod {
PublishMod::Rc
}
}