mirror of
https://github.com/TECHNOFAB11/bump2version.git
synced 2025-12-13 00:20:09 +01:00
feat: rewrite huge parts
- real config parsing - actually working parts, with support for string parts - handle readonly config (preparation for use with Nix) - cleanup cli (remove colors, fancy stuff etc., keep it minimal) - switch to tracing for logging
This commit is contained in:
parent
5b895b7939
commit
5e120a6ab8
8 changed files with 522 additions and 230 deletions
105
src/cli.rs
105
src/cli.rs
|
|
@ -1,58 +1,8 @@
|
|||
use clap::builder::styling::{AnsiColor, Effects, Styles};
|
||||
use clap::Parser;
|
||||
|
||||
fn styles() -> Styles {
|
||||
Styles::styled()
|
||||
.header(AnsiColor::Red.on_default() | Effects::BOLD)
|
||||
.usage(AnsiColor::Red.on_default() | Effects::BOLD)
|
||||
.literal(AnsiColor::Blue.on_default() | Effects::BOLD)
|
||||
.error(AnsiColor::Red.on_default() | Effects::BOLD)
|
||||
.placeholder(AnsiColor::Green.on_default())
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
#[command(
|
||||
author = "Mahmoud Harmouch",
|
||||
version,
|
||||
name = "bump2version",
|
||||
propagate_version = true,
|
||||
styles = styles(),
|
||||
help_template = r#"{before-help}{name} {version}
|
||||
{about-with-newline}
|
||||
|
||||
{usage-heading} {usage}
|
||||
|
||||
{all-args}{after-help}
|
||||
|
||||
AUTHORS:
|
||||
{author}
|
||||
"#,
|
||||
about=r#"
|
||||
🚀 Bump2version CLI
|
||||
===================
|
||||
|
||||
Bump2version CLI is a command-line tool for managing version numbers in your projects.
|
||||
Easily update version strings, create commits, and manage version control tags.
|
||||
|
||||
FEATURES:
|
||||
- Incremental Versioning: Bump major, minor, or patch versions with ease.
|
||||
- Configurability: Use a configuration file or command-line options to customize behavior.
|
||||
- Git Integration: Create commits and tags in your version control system.
|
||||
|
||||
USAGE:
|
||||
bump2version [OPTIONS]
|
||||
|
||||
EXAMPLES:
|
||||
Bump patch version:
|
||||
bump2version --current-version 1.2.3 --bump patch
|
||||
|
||||
Bump minor version and create a commit:
|
||||
bump2version --current-version 1.2.3 --bump minor --commit
|
||||
|
||||
For more information, visit: https://github.com/wiseaidev/bump2version
|
||||
"#
|
||||
)]
|
||||
pub struct Cli {
|
||||
#[command(version, name = "bump2version", propagate_version = true)]
|
||||
pub(crate) struct Cli {
|
||||
/// Config file to read most of the variables from.
|
||||
#[arg(
|
||||
short = 'c',
|
||||
|
|
@ -60,11 +10,7 @@ pub struct Cli {
|
|||
value_name = "FILE",
|
||||
default_value_t = String::from(".bumpversion.toml")
|
||||
)]
|
||||
pub config_file: String,
|
||||
|
||||
/// Version that needs to be updated.
|
||||
#[arg(long = "current-version", value_name = "VERSION")]
|
||||
pub current_version: Option<String>,
|
||||
pub(crate) config_file: String,
|
||||
|
||||
/// Part of the version to be bumped.
|
||||
#[arg(
|
||||
|
|
@ -72,50 +18,29 @@ pub struct Cli {
|
|||
value_name = "PART",
|
||||
default_value_t = String::from("patch")
|
||||
)]
|
||||
pub bump: String,
|
||||
|
||||
/// Regex parsing the version string.
|
||||
#[arg(
|
||||
long = "parse",
|
||||
value_name = "REGEX",
|
||||
default_value_t = String::from(r"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)")
|
||||
)]
|
||||
pub parse: String,
|
||||
|
||||
/// How to format what is parsed back to a version.
|
||||
#[arg(
|
||||
long = "serialize",
|
||||
value_name = "FORMAT",
|
||||
default_value_t = String::from("{major}.{minor}.{patch}")
|
||||
)]
|
||||
pub serialize: String,
|
||||
pub(crate) bump: String,
|
||||
|
||||
/// Don't write any files, just pretend.
|
||||
#[arg(short = 'n', long = "dry-run", default_value_t = false)]
|
||||
pub dry_run: bool,
|
||||
pub(crate) dry_run: bool,
|
||||
|
||||
/// New version that should be in the files.
|
||||
#[arg(long = "new-version", value_name = "VERSION")]
|
||||
pub new_version: Option<String>,
|
||||
pub(crate) new_version: Option<String>,
|
||||
|
||||
/// Create a commit in version control.
|
||||
#[arg(long = "commit", default_value_t = true)]
|
||||
pub commit: bool,
|
||||
#[arg(long = "commit")]
|
||||
pub(crate) commit: Option<bool>,
|
||||
|
||||
/// Create a tag in version control.
|
||||
#[arg(long = "tag")]
|
||||
pub tag: bool,
|
||||
pub(crate) tag: Option<bool>,
|
||||
|
||||
/// Whether to fail on a dirty git repository
|
||||
#[arg(long = "fail-on-dirty", default_value_t = false)]
|
||||
pub(crate) fail_on_dirty: bool,
|
||||
|
||||
/// Commit message.
|
||||
#[arg(
|
||||
short = 'm',
|
||||
long = "message",
|
||||
value_name = "COMMIT_MSG",
|
||||
default_value_t = String::from("Bump version: {current_version} → {new_version}")
|
||||
)]
|
||||
pub message: String,
|
||||
|
||||
/// Files to change.
|
||||
#[arg(value_name = "file")]
|
||||
pub files: Vec<String>,
|
||||
#[arg(short = 'm', long = "message", value_name = "COMMIT_MSG")]
|
||||
pub(crate) message: Option<String>,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue