Actually made it work like a cargo extension
parent
0eb6d17d68
commit
7f33e4a048
13
Cargo.toml
13
Cargo.toml
|
@ -2,8 +2,19 @@
|
|||
name = "cargo-semver"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
keywords = ["cargo", "semver"]
|
||||
categories = [
|
||||
"development-tools",
|
||||
"development-tools::cargo-plugins",
|
||||
"development-tools::build-utils",
|
||||
"command-line-utilities",
|
||||
]
|
||||
|
||||
[[bin]]
|
||||
name = "cargo-semver"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
toml_edit = { version = "0.22.20" }
|
||||
semver = { version = "1.0.23" }
|
||||
clap = { version = "4.5.16", features = ["derive"] }
|
||||
clap = { version = "4.5.16", features = ["derive", "cargo"] }
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -4,9 +4,16 @@ use clap::{command, Parser};
|
|||
use semver::Version;
|
||||
use toml_edit::{value, DocumentMut};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "cargo")]
|
||||
#[command(bin_name = "cargo")]
|
||||
enum CargoCli {
|
||||
Semver(SemverArgs),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Parser, PartialEq, Eq)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct CliArgs {
|
||||
pub struct SemverArgs {
|
||||
#[arg(long("bump-patch"), default_value_t = false)]
|
||||
pub bump_patch: bool,
|
||||
|
||||
|
@ -18,7 +25,7 @@ pub struct CliArgs {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = CliArgs::parse();
|
||||
let CargoCli::Semver(args) = CargoCli::parse();
|
||||
|
||||
if !args.bump_major && !args.bump_minor && !args.bump_patch {
|
||||
panic!("Specify which version to bump by using --bump-patch --bump-minor or --bump-major");
|
||||
|
|
Loading…
Reference in New Issue