use progit_plugin_sdk::prelude::*;
fn main() -> anyhow::Result<()> {
env_logger::init();
let script = r#"
plugin = {
name = "hello-world",
version = "1.0.0",
author = "Markus Maiwald",
description = "A simple hello world plugin",
hooks = {
on_issue_created = true,
on_issue_updated = true,
}
}
function init()
print("Hello World plugin initialized!")
print("Repository: " .. context.repo_path)
end
function on_issue_created(issue)
print("🎉 New issue created: " .. issue.title)
print(" ID: " .. issue.id)
print(" Status: " .. issue.status)
-- Return success
return { success = true, message = "Issue logged" }
end
function on_issue_updated(issue)
print("✏️ Issue updated: " .. issue.title)
print(" New status: " .. issue.status)
return { success = true }
end
"#;
let mut plugin = LuaPlugin::from_string(script, "hello-world")?;
println!("Loaded plugin: {}", plugin.metadata().name);
println!("Version: {}", plugin.metadata().version);
println!("Author: {}", plugin.metadata().author);
println!();
let context = PluginContext {
repo_path: "/home/user/my-project".to_string(),
user: Some("markus".to_string()),
env: std::env::vars().collect(),
config: Default::default(),
};
plugin.init(&context)?;
println!();
let issue = Issue {
id: "abc123".to_string(),
title: "Implement fuzzy command palette".to_string(),
description: "Add Ctrl+P fuzzy search for issues, files, and commits".to_string(),
status: "in-progress".to_string(),
tags: vec!["feature".to_string(), "tui".to_string()],
assignee: Some("markus".to_string()),
effort: Some(5),
blocked: false,
created: "2025-12-11T00:00:00Z".to_string(),
updated: "2025-12-11T00:00:00Z".to_string(),
due: Some("2025-12-13T23:59:59Z".to_string()),
metadata: Default::default(),
};
plugin.on_issue_created(&issue)?;
println!();
let mut updated_issue = issue.clone();
updated_issue.status = "done".to_string();
plugin.on_issue_updated(&updated_issue)?;
Ok(())
}