basic_usage/
basic_usage.rs

1/// Basic usage example for noob-commit
2/// 
3/// This example demonstrates how to use noob-commit programmatically
4/// 
5/// Run with: cargo run --example basic_usage
6
7use noob_commit::Commit;
8use std::env;
9
10fn main() {
11    // Example of creating a commit struct
12    let commit = Commit::new(
13        "feat: add basic usage example".to_string(),
14        "This example demonstrates how to use noob-commit programmatically and shows the basic structure of commit messages.".to_string(),
15    );
16
17    println!("Example commit title: {}", commit.title);
18    println!("Example commit description: {}", commit.description);
19    println!("\nFull commit message:\n{}", commit.to_string());
20
21    // Example of checking for API key
22    match env::var("OPENAI_API_KEY") {
23        Ok(_) => println!("✅ OpenAI API key is set"),
24        Err(_) => println!("❌ OpenAI API key is not set. Set OPENAI_API_KEY environment variable"),
25    }
26
27    println!("\nTo use noob-commit:");
28    println!("1. Stage your changes: git add .");
29    println!("2. Run: noob-commit");
30    println!("3. Or for dry run: noob-commit --dry-run");
31    println!("4. To review before commit: noob-commit --review");
32}