Skip to content

Commit 2ccedbd

Browse files
StartAutomatingStartAutomating
authored andcommitted
Adding Define (Fixes #299)
1 parent 718b735 commit 2ccedbd

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

docs/Define.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
Define
2+
------
3+
### Synopsis
4+
defines a variable
5+
6+
---
7+
### Description
8+
9+
Defines a variable using a value provided during a build
10+
11+
---
12+
### Examples
13+
#### EXAMPLE 1
14+
```PowerShell
15+
{
16+
[Define(Value={Get-Random})]$RandomNumber
17+
}.Transpile()
18+
```
19+
20+
#### EXAMPLE 2
21+
```PowerShell
22+
{
23+
[Define(Value={$global:ThisValueExistsAtBuildTime})]$MyVariable
24+
}.Transpile()
25+
```
26+
27+
---
28+
### Parameters
29+
#### **Value**
30+
31+
The value to define.
32+
When this value is provided within an attribute as a ScriptBlock, the ScriptBlock will be run at build time.
33+
34+
35+
36+
> **Type**: ```[PSObject]```
37+
38+
> **Required**: true
39+
40+
> **Position**: named
41+
42+
> **PipelineInput**:false
43+
44+
45+
46+
---
47+
#### **VariableAst**
48+
49+
The variable the definition will be applied to.
50+
51+
52+
53+
> **Type**: ```[VariableExpressionAst]```
54+
55+
> **Required**: true
56+
57+
> **Position**: named
58+
59+
> **PipelineInput**:true (ByValue)
60+
61+
62+
63+
---
64+
#### **ScriptBlock**
65+
66+
A scriptblock the definition will be applied to
67+
68+
69+
70+
> **Type**: ```[ScriptBlock]```
71+
72+
> **Required**: true
73+
74+
> **Position**: named
75+
76+
> **PipelineInput**:true (ByValue)
77+
78+
79+
80+
---
81+
#### **VariableName**
82+
83+
The name of the variable. If define is applied as an attribute of a variable, this does not need to be provided.
84+
85+
86+
87+
> **Type**: ```[String]```
88+
89+
> **Required**: false
90+
91+
> **Position**: named
92+
93+
> **PipelineInput**:false
94+
95+
96+
97+
---
98+
### Syntax
99+
```PowerShell
100+
Define -Value <PSObject> -VariableAst <VariableExpressionAst> [-VariableName <String>] [<CommonParameters>]
101+
```
102+
```PowerShell
103+
Define -Value <PSObject> -ScriptBlock <ScriptBlock> [-VariableName <String>] [<CommonParameters>]
104+
```
105+
---
106+

0 commit comments

Comments
 (0)