This commit is contained in:
38
examples/basic_usage.rs
Normal file
38
examples/basic_usage.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use git_commit_prefix_gen::{Analyzer, CommitConvention};
|
||||
|
||||
fn main() {
|
||||
let convention = CommitConvention::default();
|
||||
let analyzer = Analyzer::with_convention(convention);
|
||||
|
||||
println!("Git Commit Prefix Generator - Basic Usage Example");
|
||||
println!("================================================\n");
|
||||
|
||||
println!("This example demonstrates how to use the library to analyze git changes");
|
||||
println!("and generate commit message prefixes.\n");
|
||||
|
||||
println!("Current directory: {:?}", std::env::current_dir().unwrap());
|
||||
|
||||
match std::env::current_dir() {
|
||||
Ok(path) => match analyzer.analyze(&path) {
|
||||
Ok(changes) => {
|
||||
println!("Found {} changed files", changes.len());
|
||||
let suggestions = analyzer.generate_suggestions(&changes);
|
||||
|
||||
if suggestions.is_empty() {
|
||||
println!("\nNo suggestions available (no changes detected)");
|
||||
} else {
|
||||
for suggestion in &suggestions {
|
||||
println!("\nSuggested commit: {}", suggestion);
|
||||
if let Some(scope) = &suggestion.scope {
|
||||
println!(" Type: {}", suggestion.commit_type);
|
||||
println!(" Scope: {}", scope);
|
||||
println!(" Confidence: {:.0}%", suggestion.confidence * 100.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => println!("Error analyzing changes: {}", e),
|
||||
},
|
||||
Err(e) => println!("Error getting current directory: {}", e),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user