cuddle-v2/cuddle/src/model.rs
kjuulh 2cd9509fcb
feat: rename cuddle_cli -> cuddle
Signed-off-by: kjuulh <contact@kjuulh.io>
2023-08-12 21:41:07 +02:00

80 lines
1.9 KiB
Rust

use std::collections::HashMap;
use serde::Deserialize;
#[derive(Debug, Clone, PartialEq, Deserialize)]
#[serde(untagged)]
pub enum CuddleBase {
Bool(bool),
String(String),
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct CuddleShellScriptArgEnv {
pub key: String,
pub description: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct CuddleShellScriptArgFlag {
pub name: String,
pub description: Option<String>,
pub required: Option<bool>,
pub default_value: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
#[serde(tag = "type")]
pub enum CuddleShellScriptArg {
#[serde(alias = "env")]
Env(CuddleShellScriptArgEnv),
#[serde(alias = "flag")]
Flag(CuddleShellScriptArgFlag),
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct CuddleShellScript {
pub description: Option<String>,
pub args: Option<HashMap<String, CuddleShellScriptArg>>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct CuddleDaggerScript {
pub description: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct CuddleLuaScript {
pub description: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
#[serde(tag = "type")]
pub enum CuddleScript {
#[serde(alias = "shell")]
Shell(CuddleShellScript),
#[serde(alias = "dagger")]
Dagger(CuddleDaggerScript),
#[serde(alias = "lua")]
Lua(CuddleLuaScript),
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct CuddlePlan {
pub base: CuddleBase,
pub vars: Option<HashMap<String, String>>,
pub scripts: Option<HashMap<String, CuddleScript>>,
}
#[derive(Debug, Clone)]
#[allow(dead_code)]
pub struct CuddleVariable {
pub name: String,
pub value: String,
}
impl CuddleVariable {
pub fn new(name: String, value: String) -> Self {
Self { name, value }
}
}