Compare commits
3 Commits
91e80b82f3
...
55d4504645
Author | SHA1 | Date | |
---|---|---|---|
55d4504645 | |||
d4341b3b40 | |||
fb58f88f5e |
@ -6,4 +6,5 @@ description = "PowerShell Scripts for EVERYONE!"
|
||||
repository = "https://git.itsscb.de/itsscb/BefehlsWerk"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.219", features = ["derive", "rc"] }
|
||||
serde_json = "1.0.140"
|
||||
|
@ -120,7 +120,9 @@ foreach ($param in $paramBlock.Parameters) {
|
||||
} elseif ($attr.TypeName.Name -eq 'ValidateSet') {
|
||||
$val.values = $attr.PositionalArguments.Value
|
||||
} elseif ($attr.TypeName.Name -eq 'ValidateScript') {
|
||||
$val.script = $attr.PositionalArguments.ScriptBlock.Extent.Text
|
||||
$val.value = $attr.PositionalArguments.ScriptBlock.Extent.Text
|
||||
} elseif ($attr.TypeName.Name -eq 'ValidatePattern') {
|
||||
$val.value = $attr.PositionalArguments.Value
|
||||
}
|
||||
|
||||
$validations += [pscustomobject]$val
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
# Accepts pipeline input by value
|
||||
[Parameter(ValueFromPipeline = $true, ParameterSetName = 'Set2')]
|
||||
[ValidatePattern("^[a-zA-Z0-9]*$")]
|
||||
[string]$InputObject,
|
||||
|
||||
# Accepts pipeline input by property name
|
||||
|
@ -1,3 +1,5 @@
|
||||
mod script;
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
1
src/script.rs
Normal file
1
src/script.rs
Normal file
@ -0,0 +1 @@
|
||||
mod parameter;
|
38
src/script/parameter.rs
Normal file
38
src/script/parameter.rs
Normal file
@ -0,0 +1,38 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validation::Validation;
|
||||
|
||||
mod validation;
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Parameter {
|
||||
name: Arc<str>,
|
||||
data_type: DataType,
|
||||
is_array: bool,
|
||||
aliases: Vec<Arc<str>>,
|
||||
description: Option<Arc<str>>,
|
||||
help_message: Option<Arc<str>>,
|
||||
parameter_sets: Vec<ParameterSet>,
|
||||
validations: Vec<Validation>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct ParameterSet {
|
||||
name: Arc<str>,
|
||||
mandatory: bool,
|
||||
position: Option<u8>,
|
||||
value_from_pipeline: Option<bool>,
|
||||
value_from_pipeline_by_property_name: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum DataType {
|
||||
String,
|
||||
Int32,
|
||||
Int64,
|
||||
Switch,
|
||||
Bool,
|
||||
Credential,
|
||||
SecureString,
|
||||
}
|
18
src/script/parameter/validation.rs
Normal file
18
src/script/parameter/validation.rs
Normal file
@ -0,0 +1,18 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum Validation {
|
||||
#[serde(rename = "ValidateNotNullOrEmpty")]
|
||||
NotNullOrEmpty,
|
||||
#[serde(rename = "ValidateRange")]
|
||||
Range { min: i32, max: i32 },
|
||||
#[serde(rename = "ValidateScript")]
|
||||
Script { value: Arc<str> },
|
||||
#[serde(rename = "ValidatePattern")]
|
||||
Pattern { value: Arc<str> },
|
||||
#[serde(rename = "ValidateSet")]
|
||||
Set { values: Vec<Arc<str>> },
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user