dtolnay / semver

Parser and evaluator for Cargo's flavor of Semantic Versioning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request for additional functionality

TrentDaniel opened this issue · comments

Hi, I'm writing a project management tool which can be used to update the version of the target project. I was hoping that I would be able to do so through this crate, but I can't find a way to manipulate the Version object other than simply overwriting it.

@dtolnay , I'm willing to write the new feature myself and open a PR, but before doing that I wanted to make sure that this kind of feature would be welcome in this project, and that someone would be available to review and merge the PR?

I'm open to suggestions on what the feature interface would look like, but I was thinking that we could start with the following:

impl Version {
    /// Increments the major version
    pub fn increment_major(&mut self, number_of_increments: u64);
    /// Increments the minor version
    pub fn increment_minor(&mut self, number_of_increments: u64);
    /// Increments the patch version
    pub fn increment_patch(&mut self, number_of_increments: u64);
    /// Sets the pre-release version on a pre-existing Version instance
    pub fn with_pre_release(&mut self, pre: Prerelease);
    /// Sets the build metadata on a pre-existing Version instance
    pub fn with_build(&mut self, build: BuildMetadata);
}

While not needed for my immediate use case, it might also be nice to add getters for all version components, such as major, prerelease, etc., for the sake of completeness.

If any of these features are already present in the API, and I just didn't see them, please let me know!

I would prefer not to add any of these. The fields on Version are public, so you'd just write version.build = build. There is no need for a with_build method.