1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(
    missing_docs,
    rustdoc::broken_intra_doc_links,
    rustdoc::private_intra_doc_links,
    rustdoc::invalid_rust_codeblocks,
    rustdoc::invalid_codeblock_attributes
)]
#![cfg_attr(docsrs, feature(rustdoc_missing_doc_code_examples))]
#![cfg_attr(docsrs, warn(rustdoc::missing_doc_code_examples))]
#![cfg_attr(docsrs, warn(rustdoc::invalid_codeblock_attributes))]

//! # Calculate next semantic bump and/or version number
//!
//! Calculates the next semantic bump and/or version number based on
//! the current version number and the conventional commits made
//! since the last version has been released.
//!
//! ## Usage
//!
//! Add the dependency to Cargo.toml
//!
//! ```toml
//! [dependencies]
//! nextsv = "0.8.7"
//! ```
//!
//! Calculation workflow:
//! 1. Create the configuration
//! 2. Build the calculator
//! 3. Report the calculation
//!
//! Report the results from the calculator
//!
//! ```rust
//! #   use nextsv::{CalculatorConfig, ForceBump, Hierarchy};
//! #   use std::ffi::OsString;
//! #
//! #   fn main() -> Result<(), nextsv::Error> {
//! #   struct Args {
//! #       prefix: String,
//! #       level: bool,
//! #       number: bool,
//! #       force: Option<ForceBump>,
//! #       require: Vec<OsString>,
//! #       enforce_level: Hierarchy,
//! #       check: Option<Hierarchy>,
//! #       
//! #   };
//!     // arguments collected from CLI
//!     let args = Args {
//!         prefix: String::from("v"),
//!         level: true,
//!         number: true,
//!         force: None,
//!         require: vec![OsString::from("README.md"), OsString::from("CHANGES.md"), ],
//!         enforce_level: Hierarchy::Feature,
//!         check: None,
//!     };
//!
//!     // 1. Create the configuration
//!
//!     let mut calculator_config = CalculatorConfig::new();
//!
//!     // Set the version number prefix
//!     calculator_config = calculator_config.set_prefix(&args.prefix);
//!
//!     // What do we want to output?    
//!     calculator_config = calculator_config.set_bump_report(args.level);
//!     calculator_config = calculator_config.set_version_report(args.number);
//!
//!     // Is the bump level being forced?
//!     if let Some(force) = args.force {
//!         calculator_config = calculator_config.set_force_bump(force);
//!     };
//!
//!     // Are there files that must be updated? What change level should they be enforced at?
//!     if !args.require.is_empty() {
//!         calculator_config = calculator_config.add_required_files(args.require);
//!         calculator_config = calculator_config.set_required_enforcement(args.enforce_level);
//!     };
//!
//!     // Is three a threshold set that must be met before proceeding with a change?
//!     if let Some(check_level) = args.check {
//!         calculator_config = calculator_config.set_reporting_threshold(check_level);
//!     }
//!
//!     // 2. Build the calculator
//!     // Apply the config and create a calculator
//!     let calculator = calculator_config.build()?;
//!     
//!     // 3. Report the calculations
//!     println!("{}", calculator.report());
//!
//! #    Ok(())
//! # }
//! ```

mod calculator;
mod error;
#[cfg(test)]
mod test_utils;
mod version;

pub use calculator::{Calculator, CalculatorConfig, ForceBump, Hierarchy};
pub use error::Error;
// pub use version::VersionTag;