cargo_tangle/create/
types.rs

1use clap::{Args, ValueEnum};
2
3#[derive(Debug, Clone, Args)]
4pub struct CreateArgs {
5    /// The name of the blueprint
6    #[arg(short, long, value_name = "NAME", env = "NAME")]
7    pub name: String,
8
9    #[command(flatten)]
10    pub blueprint_type: BlueprintType,
11}
12
13#[derive(Debug, Clone, Args)]
14#[group(required = false, multiple = false)]
15pub struct BlueprintType {
16    /// Create a Tangle blueprint
17    #[arg(long, conflicts_with = "eigenlayer")]
18    pub tangle: bool,
19
20    /// Create an EigenLayer blueprint
21    #[arg(long, value_name = "VARIANT", value_enum, num_args = 0..=1, default_value = "bls")]
22    pub eigenlayer: Option<EigenlayerVariant>,
23}
24
25impl Default for BlueprintType {
26    fn default() -> Self {
27        Self {
28            tangle: true,
29            eigenlayer: None,
30        }
31    }
32}
33
34#[derive(Debug, Default, Clone, Copy, ValueEnum)]
35pub enum EigenlayerVariant {
36    #[default]
37    BLS,
38    ECDSA,
39}
40
41impl BlueprintType {
42    pub fn get_type(&self) -> Option<BlueprintVariant> {
43        if self.tangle {
44            Some(BlueprintVariant::Tangle)
45        } else {
46            self.eigenlayer.map(BlueprintVariant::Eigenlayer)
47        }
48    }
49}
50
51#[derive(Debug, Clone)]
52pub enum BlueprintVariant {
53    Tangle,
54    Eigenlayer(EigenlayerVariant),
55}