chore: rename sdk

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-10-26 21:35:28 +02:00
parent 938680cb75
commit 6c4a05e43d
Signed by: kjuulh
GPG Key ID: D85D7535F18F35FA
7 changed files with 18 additions and 17 deletions

8
Cargo.lock generated
View File

@ -7,7 +7,7 @@ name = "action"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cuddle-actions 0.2.0 (git+ssh://git@git.front.kjuulh.io/kjuulh/cuddle-v2)", "cuddle-actions",
"tokio", "tokio",
] ]
@ -248,21 +248,21 @@ dependencies = [
[[package]] [[package]]
name = "cuddle-actions" name = "cuddle-actions"
version = "0.2.0" version = "0.2.0"
source = "git+ssh://git@git.front.kjuulh.io/kjuulh/cuddle-v2#37bf97972b7ef70727e4438572de552bef74aa9a"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
"pretty_assertions",
"serde", "serde",
"serde_json", "serde_json",
] ]
[[package]] [[package]]
name = "cuddle-actions" name = "cuddle-actions-sdk"
version = "0.2.0" version = "0.2.0"
source = "git+ssh://git@git.front.kjuulh.io/kjuulh/cuddle-v2#37bf97972b7ef70727e4438572de552bef74aa9a"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
"pretty_assertions",
"serde", "serde",
"serde_json", "serde_json",
] ]

View File

@ -1,5 +1,5 @@
[package] [package]
name = "cuddle-actions" name = "cuddle-actions-sdk"
edition = "2021" edition = "2021"
version.workspace = true version.workspace = true

View File

@ -1,9 +1,9 @@
use cuddle_actions::AddActionOptions; use cuddle_actions_sdk::AddActionOptions;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
#[test] #[test]
fn test_can_schema_no_actions() -> anyhow::Result<()> { 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); assert_eq!("[]", &output);
@ -12,7 +12,7 @@ fn test_can_schema_no_actions() -> anyhow::Result<()> {
#[test] #[test]
fn test_can_schema_simple_action() -> anyhow::Result<()> { 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()) .add_action("something", || Ok(()), &AddActionOptions::default())
.get_pretty_actions()?; .get_pretty_actions()?;
@ -31,7 +31,7 @@ fn test_can_schema_simple_action() -> anyhow::Result<()> {
#[test] #[test]
fn test_can_call_simple_action() -> anyhow::Result<()> { fn test_can_call_simple_action() -> anyhow::Result<()> {
cuddle_actions::CuddleActions::default() cuddle_actions_sdk::CuddleActions::default()
.add_action("something", || Ok(()), &AddActionOptions::default()) .add_action("something", || Ok(()), &AddActionOptions::default())
.execute_from(vec!["cuddle-actions", "do", "something"])?; .execute_from(vec!["cuddle-actions", "do", "something"])?;
@ -40,7 +40,7 @@ fn test_can_call_simple_action() -> anyhow::Result<()> {
#[test] #[test]
fn test_can_fail_on_unknown_command() -> anyhow::Result<()> { 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", "cuddle-actions",
"do", "do",
"something", "something",
@ -53,7 +53,7 @@ fn test_can_fail_on_unknown_command() -> anyhow::Result<()> {
#[test] #[test]
fn test_can_cmd_can_fail() -> anyhow::Result<()> { fn test_can_cmd_can_fail() -> anyhow::Result<()> {
let res = cuddle_actions::CuddleActions::default() let res = cuddle_actions_sdk::CuddleActions::default()
.add_action( .add_action(
"something", "something",
|| anyhow::bail!("failed to run cmd"), || anyhow::bail!("failed to run cmd"),

View File

@ -5,5 +5,5 @@ edition = "2021"
[dependencies] [dependencies]
anyhow = "1.0.91" 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"] } tokio = { version = "1.41.0", features = ["full"] }

View File

@ -2,7 +2,7 @@ use cuddle_actions::AddActionOptions;
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
cuddle_actions::CuddleActions::default() cuddle_actions_sdk::CuddleActions::default()
.add_action( .add_action(
"something", "something",
|| { || {

View File

@ -173,22 +173,23 @@ impl Drop for TempGuard {
} }
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize, Clone)]
struct CuddleActionsSchema { struct CuddleActionsSchema {
actions: Vec<CuddleActionSchema>, actions: Vec<CuddleActionSchema>,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize, Clone)]
struct CuddleActionSchema { struct CuddleActionSchema {
name: String, name: String,
} }
impl CuddleActionsSchema { impl CuddleActionsSchema {
fn to_executable(self, action_path: &Path) -> anyhow::Result<ExecutableActions> { fn to_executable(&self, action_path: &Path) -> anyhow::Result<ExecutableActions> {
Ok(ExecutableActions { Ok(ExecutableActions {
actions: self actions: self
.actions .actions
.into_iter() .iter()
.cloned()
.map(|a| { .map(|a| {
let name = a.name.clone(); let name = a.name.clone();
let action_path = action_path.to_string_lossy().to_string(); let action_path = action_path.to_string_lossy().to_string();