Add clap CLI, lib crate, unit test, and criterion benchmark
Minimal scaffold before turning this into a Nix flake template. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ALEXkc7pTro7tF1WcUuKb
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
pub fn greet(name: &str) -> String {
|
||||
format!("Hello, {name}!")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn greets_by_name() {
|
||||
assert_eq!(greet("world"), "Hello, world!");
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
use clap::Parser;
|
||||
use rust_template::greet;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(version, about)]
|
||||
struct Cli {
|
||||
/// Name to greet
|
||||
#[arg(default_value = "world")]
|
||||
name: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
println!("{}", greet(&cli.name));
|
||||
}
|
||||
Reference in New Issue
Block a user