diff --git a/Cargo.lock b/Cargo.lock index 523efe3..7e8af84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,7 +7,7 @@ name = "action" version = "0.1.0" dependencies = [ "anyhow", - "cuddle-actions 0.2.0 (git+ssh://git@git.front.kjuulh.io/kjuulh/cuddle-v2)", + "cuddle-actions", "tokio", ] @@ -248,21 +248,21 @@ dependencies = [ [[package]] name = "cuddle-actions" version = "0.2.0" +source = "git+ssh://git@git.front.kjuulh.io/kjuulh/cuddle-v2#37bf97972b7ef70727e4438572de552bef74aa9a" dependencies = [ "anyhow", "clap", - "pretty_assertions", "serde", "serde_json", ] [[package]] -name = "cuddle-actions" +name = "cuddle-actions-sdk" version = "0.2.0" -source = "git+ssh://git@git.front.kjuulh.io/kjuulh/cuddle-v2#37bf97972b7ef70727e4438572de552bef74aa9a" dependencies = [ "anyhow", "clap", + "pretty_assertions", "serde", "serde_json", ] diff --git a/crates/cuddle-actions/Cargo.toml b/crates/cuddle-actions-sdk/Cargo.toml similarity index 89% rename from crates/cuddle-actions/Cargo.toml rename to crates/cuddle-actions-sdk/Cargo.toml index f82bdad..72096d8 100644 --- a/crates/cuddle-actions/Cargo.toml +++ b/crates/cuddle-actions-sdk/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cuddle-actions" +name = "cuddle-actions-sdk" edition = "2021" version.workspace = true diff --git a/crates/cuddle-actions/src/lib.rs b/crates/cuddle-actions-sdk/src/lib.rs similarity index 100% rename from crates/cuddle-actions/src/lib.rs rename to crates/cuddle-actions-sdk/src/lib.rs diff --git a/crates/cuddle-actions/tests/mod.rs b/crates/cuddle-actions-sdk/tests/mod.rs similarity index 75% rename from crates/cuddle-actions/tests/mod.rs rename to crates/cuddle-actions-sdk/tests/mod.rs index 155ba1a..f0d9642 100644 --- a/crates/cuddle-actions/tests/mod.rs +++ b/crates/cuddle-actions-sdk/tests/mod.rs @@ -1,9 +1,9 @@ -use cuddle_actions::AddActionOptions; +use cuddle_actions_sdk::AddActionOptions; use pretty_assertions::assert_eq; #[test] fn test_can_schema_no_actions() -> anyhow::Result<()> { - let output = cuddle_actions::CuddleActions::default().get_pretty_actions()?; + let output = cuddle_actions_sdk::CuddleActions::default().get_pretty_actions()?; assert_eq!("[]", &output); @@ -12,7 +12,7 @@ fn test_can_schema_no_actions() -> anyhow::Result<()> { #[test] fn test_can_schema_simple_action() -> anyhow::Result<()> { - let output = cuddle_actions::CuddleActions::default() + let output = cuddle_actions_sdk::CuddleActions::default() .add_action("something", || Ok(()), &AddActionOptions::default()) .get_pretty_actions()?; @@ -31,7 +31,7 @@ fn test_can_schema_simple_action() -> anyhow::Result<()> { #[test] fn test_can_call_simple_action() -> anyhow::Result<()> { - cuddle_actions::CuddleActions::default() + cuddle_actions_sdk::CuddleActions::default() .add_action("something", || Ok(()), &AddActionOptions::default()) .execute_from(vec!["cuddle-actions", "do", "something"])?; @@ -40,7 +40,7 @@ fn test_can_call_simple_action() -> anyhow::Result<()> { #[test] fn test_can_fail_on_unknown_command() -> anyhow::Result<()> { - let res = cuddle_actions::CuddleActions::default().execute_from(vec![ + let res = cuddle_actions_sdk::CuddleActions::default().execute_from(vec![ "cuddle-actions", "do", "something", @@ -53,7 +53,7 @@ fn test_can_fail_on_unknown_command() -> anyhow::Result<()> { #[test] fn test_can_cmd_can_fail() -> anyhow::Result<()> { - let res = cuddle_actions::CuddleActions::default() + let res = cuddle_actions_sdk::CuddleActions::default() .add_action( "something", || anyhow::bail!("failed to run cmd"), diff --git a/crates/cuddle/examples/actions/project/actions/rust/Cargo.toml b/crates/cuddle/examples/actions/project/actions/rust/Cargo.toml index 90e3f6b..32f337e 100644 --- a/crates/cuddle/examples/actions/project/actions/rust/Cargo.toml +++ b/crates/cuddle/examples/actions/project/actions/rust/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" [dependencies] anyhow = "1.0.91" -cuddle-actions = { git = "ssh://git@git.front.kjuulh.io/kjuulh/cuddle-v2", version = "0.2.0" } +cuddle-actions-sdk = { git = "ssh://git@git.front.kjuulh.io/kjuulh/cuddle-v2", version = "0.2.0" } tokio = { version = "1.41.0", features = ["full"] } diff --git a/crates/cuddle/examples/actions/project/actions/rust/src/main.rs b/crates/cuddle/examples/actions/project/actions/rust/src/main.rs index cf4e9e7..b0f182d 100644 --- a/crates/cuddle/examples/actions/project/actions/rust/src/main.rs +++ b/crates/cuddle/examples/actions/project/actions/rust/src/main.rs @@ -2,7 +2,7 @@ use cuddle_actions::AddActionOptions; #[tokio::main] async fn main() -> anyhow::Result<()> { - cuddle_actions::CuddleActions::default() + cuddle_actions_sdk::CuddleActions::default() .add_action( "something", || { diff --git a/crates/cuddle/src/actions/rust_builder.rs b/crates/cuddle/src/actions/rust_builder.rs index 948e2c1..ad90941 100644 --- a/crates/cuddle/src/actions/rust_builder.rs +++ b/crates/cuddle/src/actions/rust_builder.rs @@ -173,22 +173,23 @@ impl Drop for TempGuard { } } -#[derive(Debug, Deserialize)] +#[derive(Debug, Deserialize, Clone)] struct CuddleActionsSchema { actions: Vec, } -#[derive(Debug, Deserialize)] +#[derive(Debug, Deserialize, Clone)] struct CuddleActionSchema { name: String, } impl CuddleActionsSchema { - fn to_executable(self, action_path: &Path) -> anyhow::Result { + fn to_executable(&self, action_path: &Path) -> anyhow::Result { Ok(ExecutableActions { actions: self .actions - .into_iter() + .iter() + .cloned() .map(|a| { let name = a.name.clone(); let action_path = action_path.to_string_lossy().to_string();