chore: rename sdk
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
938680cb75
commit
6c4a05e43d
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -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",
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "cuddle-actions"
|
||||
name = "cuddle-actions-sdk"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
|
@ -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"),
|
@ -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"] }
|
||||
|
@ -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",
|
||||
|| {
|
||||
|
@ -173,22 +173,23 @@ impl Drop for TempGuard {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
struct CuddleActionsSchema {
|
||||
actions: Vec<CuddleActionSchema>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
struct CuddleActionSchema {
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl CuddleActionsSchema {
|
||||
fn to_executable(self, action_path: &Path) -> anyhow::Result<ExecutableActions> {
|
||||
fn to_executable(&self, action_path: &Path) -> anyhow::Result<ExecutableActions> {
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user