Skip to content

Commit 630f25a

Browse files
StartAutomatingStartAutomating
authored andcommitted
Updating PipeScript.HelpOut.ps1 (including topics, re #132)
1 parent b8e1210 commit 630f25a

File tree

1 file changed

+206
-7
lines changed

1 file changed

+206
-7
lines changed

docs/README.md

Lines changed: 206 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,211 @@
1-
Files in this directory and it's subdirectories generate wrappers for PipeScript and PowerShell.
1+
This directory and it's subdirectories contain syntax changes that enable common programming scenarios in PowerShell and PipeScript.
22

3-
These wrappers allow PipeScript or PowerShell to be called from other programming languages.
43

4+
|DisplayName |Synopsis |
5+
|------------------------------------------------|---------------------------------------------------------|
6+
|[Dot](Dot.psx.ps1) |[Dot Notation](Dot.psx.ps1) |
7+
|[EqualityComparison](EqualityComparison.psx.ps1)|[Allows equality comparison.](EqualityComparison.psx.ps1)|
8+
|[PipedAssignment](PipedAssignment.psx.ps1) |[Piped Assignment Transpiler](PipedAssignment.psx.ps1) |
9+
|[RegexLiteral](RegexLiteral.psx.ps1) |[Regex Literal Transpiler](RegexLiteral.psx.ps1) |
510

6-
|DisplayName |Synopsis |
7-
|------------------------------------------|---------------------------------------------------------------------|
8-
|[Bash](Bash.psx.ps1) |[Wraps PowerShell in a Bash Script](Bash.psx.ps1) |
9-
|[Batch](Batch.psx.ps1) |[Wraps PowerShell in a Windows Batch Script](Batch.psx.ps1) |
10-
|[BatchPowerShell](BatchPowerShell.psx.ps1)|[Wraps PowerShell in a Windows Batch Script](BatchPowerShell.psx.ps1)|
1111

1212

13+
14+
## Dot Example 1
15+
16+
17+
~~~PowerShell
18+
.> {
19+
[DateTime]::now | .Month .Day .Year
20+
}
21+
~~~
22+
23+
## Dot Example 2
24+
25+
26+
~~~PowerShell
27+
.> {
28+
"abc", "123", "abc123" | .Length
29+
}
30+
~~~
31+
32+
## Dot Example 3
33+
34+
35+
~~~PowerShell
36+
.> { 1.99 | .ToString 'C' [CultureInfo]'gb-gb' }
37+
~~~
38+
39+
## Dot Example 4
40+
41+
42+
~~~PowerShell
43+
.> { 1.99 | .ToString('C') }
44+
~~~
45+
46+
## Dot Example 5
47+
48+
49+
~~~PowerShell
50+
.> { 1..5 | .Number { $_ } .Even { -not ($_ % 2) } .Odd { ($_ % 2) -as [bool]} }
51+
~~~
52+
53+
## Dot Example 6
54+
55+
56+
~~~PowerShell
57+
.> { .ID { Get-Random } .Count { 0 } .Total { 10 }}
58+
~~~
59+
60+
## Dot Example 7
61+
62+
63+
~~~PowerShell
64+
.> {
65+
# Declare a new object
66+
.Property = "ConstantValue" .Numbers = 1..100 .Double = {
67+
param($n)
68+
$n * 2
69+
} .EvenNumbers = {
70+
$this.Numbers | Where-Object { -not ($_ % 2)}
71+
} .OddNumbers = {
72+
$this.Numbers | Where-Object { $_ % 2}
73+
}
74+
}
75+
~~~
76+
77+
## EqualityComparison Example 1
78+
79+
80+
~~~PowerShell
81+
Invoke-PipeScript -ScriptBlock {
82+
$a = 1
83+
if ($a == 1 ) {
84+
"A is $a"
85+
}
86+
}
87+
~~~
88+
89+
## EqualityComparison Example 2
90+
91+
92+
~~~PowerShell
93+
{
94+
$a == "b"
95+
} | .>PipeScript
96+
~~~
97+
98+
## PipedAssignment Example 1
99+
100+
101+
~~~PowerShell
102+
{
103+
$Collection |=| Where-Object Name -match $Pattern
104+
} | .>PipeScript
105+
106+
# This will become:
107+
108+
$Collection = $Collection | Where-Object Name -match $pattern
109+
~~~
110+
111+
## PipedAssignment Example 2
112+
113+
114+
~~~PowerShell
115+
{
116+
$Collection |=| Where-Object Name -match $pattern | Select-Object -ExpandProperty Name
117+
} | .>PipeScript
118+
119+
# This will become
120+
121+
$Collection = $Collection |
122+
Where-Object Name -match $pattern |
123+
Select-Object -ExpandProperty Name
124+
~~~
125+
126+
## RegexLiteral Example 1
127+
128+
129+
~~~PowerShell
130+
{
131+
'/[a|b]/'
132+
} | .>PipeScript
133+
134+
# This will become:
135+
136+
[regex]::new('[a|b]', 'IgnoreCase')
137+
~~~
138+
139+
## RegexLiteral Example 2
140+
141+
142+
~~~PowerShell
143+
Invoke-PipeScript {
144+
'/[a|b]/'.Matches('ab')
145+
}
146+
~~~
147+
148+
## RegexLiteral Example 3
149+
150+
151+
~~~PowerShell
152+
{
153+
"/[$a|$b]/"
154+
} | .>PipeScript
155+
156+
# This will become:
157+
158+
[regex]::new("[$a|$b]", 'IgnoreCase')
159+
~~~
160+
161+
## RegexLiteral Example 4
162+
163+
164+
~~~PowerShell
165+
{
166+
@'
167+
/
168+
# Heredocs Regex literals will have IgnorePatternWhitespace by default, which allows comments
169+
^ # Match the string start
170+
(?<indent>\s{0,1})
171+
/
172+
'@
173+
} | .>PipeScript
174+
175+
# This will become:
176+
177+
[regex]::new(@'
178+
# Heredocs Regex literals will have IgnorePatternWhitespace by default, which allows comments
179+
^ # Match the string start
180+
(?<indent>\s{0,1})
181+
'@, 'IgnorePatternWhitespace,IgnoreCase')
182+
~~~
183+
184+
## RegexLiteral Example 5
185+
186+
187+
~~~PowerShell
188+
$Keywords = "looking", "for", "these", "words"
189+
190+
{
191+
@"
192+
/
193+
# Double quoted heredocs can still contain variables
194+
[\s\p{P}]{0,1} # Whitespace or punctuation
195+
$($Keywords -join '|') # followed by keywords
196+
[\s\p{P}]{0,1} # followed by whitespace or punctuation
197+
/
198+
"@
199+
} | .>PipeScript
200+
201+
202+
# This will become:
203+
204+
[regex]::new(@"
205+
# Double quoted heredocs can still contain variables
206+
[\s\p{P}]{0,1} # Whitespace or punctuation
207+
$($Keywords -join '|') # followed by keywords
208+
[\s\p{P}]{0,1} # followed by whitespace or punctuation
209+
"@, 'IgnorePatternWhitespace,IgnoreCase')
210+
~~~
211+

0 commit comments

Comments
 (0)