Skip to content

Commit 4c9575a

Browse files
Merge pull request #170 from StartAutomating/PipeScriptFormattingAndFun
Pipe script formatting and fun
2 parents dc096e4 + 71d27ed commit 4c9575a

18 files changed

+1799
-979
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.1:
2+
* PipeScript can now Transpile Protocols (Fixes #168)
3+
* PipeScript can transpile http[s] protocol (Fixes #169)
4+
* PipeScript now formats the AST (Fixes #166)
5+
* Added .IsAssigned to CommandAST/PipelineAST (Fixes #167)
6+
---
7+
18
## 0.0.14:
29
* New Transpilers:
310
* [RemoveParameter] (#159)

Formatting/Ast.format.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Write-FormatView -TypeName 'System.Management.Automation.Language.Ast' -Action {
2+
Write-FormatViewExpression -Enumerate -Property Tokens -ControlName PSToken
3+
}

Formatting/PSToken.control.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Write-FormatView -AsControl -Name "PSToken" -TypeName "n/a" -Action {
2+
Write-FormatViewExpression -If {
3+
$_.PreviousToken -and $_.Text
4+
} -ScriptBlock {
5+
$token = $_
6+
$prevEnd = $_.PreviousToken.Start + $_.PreviousToken.Length
7+
$substring = $_.Text.Substring($prevEnd, $token.Start - $prevEnd)
8+
if ($substring) { $substring} else { ''}
9+
}
10+
11+
Write-FormatViewExpression -If {
12+
$_.Type -eq 'Comment'
13+
} -ForegroundColor Success -Property Content
14+
15+
Write-FormatViewExpression -If {
16+
$_.Type -in 'Keyword', 'String'
17+
} -ForegroundColor Verbose -Property Content
18+
19+
Write-FormatViewExpression -If {
20+
$_.Type -in 'Variable', 'Command'
21+
} -ForegroundColor Warning -ScriptBlock {
22+
$_.Content
23+
}
24+
25+
Write-FormatViewExpression -If {
26+
$_.Type -in 'Operator','GroupStart', 'GroupEnd'
27+
} -ForegroundColor Blue -Property Content
28+
29+
Write-FormatViewExpression -If {
30+
$_.Type -notin 'Comment', 'GroupStart', 'GroupEnd', 'Variable', 'Operator', 'Command','Keyword', 'String'
31+
} -Property Content
32+
}

0 commit comments

Comments
 (0)