Lines
65 %
Functions
71.43 %
Branches
100 %
use supp_macro::command;
// Simple debug test to see what the macro generates
#[derive(Debug, Clone)]
pub enum Argument {
String(String),
}
#[derive(Debug)]
pub enum CmdError {
Args(String),
impl std::fmt::Display for CmdError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
impl std::error::Error for CmdError {}
pub enum CmdResult {
Success(String),
impl TryFrom<Argument> for String {
type Error = CmdError;
fn try_from(arg: Argument) -> Result<Self, Self::Error> {
match arg {
Argument::String(s) => Ok(s),
// Try the most basic case first - progressive types approach
command! {
TestCommand {
} => {
Ok(Some(CmdResult::Success("test".to_string())))
#[tokio::test]
async fn test_basic_macro() {
// Test that it compiles and actually works with progressive types
let result = TestCommand::new().run().await.unwrap();
assert!(result.is_some());
if let Some(CmdResult::Success(msg)) = result {
assert_eq!(msg, "test");
} else {
panic!("Expected Success result");
#[test]
fn test_generated_struct() {
// Test that the command struct was generated
let _cmd = TestCommand;