Skip to content

Commit de6f5fd

Browse files
author
James Brundage
committed
Adding \Types\PipeScript.Sentence (Fixes #243)
1 parent 412e6b5 commit de6f5fd

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@{
2+
Parameter = 'Parameters'
3+
Argument = 'Arguments'
4+
ArgumentList = 'Arguments'
5+
}

Types/PipeScript.Sentence/Run.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
if (-not $this.Keyword) {
2+
throw "Sentence lacks a keyword"
3+
}
4+
5+
if (-not $this.Command) {
6+
throw "Sentence has no command"
7+
}
8+
9+
$parameters = $this.Parameters
10+
$arguments = $this.Arguments
11+
12+
if (-not $parameters -and -not $arguments) {
13+
& $this.Command
14+
}
15+
elseif (-not $arguments) {
16+
& $this.Command @parameters
17+
}
18+
elseif (-not $parameters) {
19+
& $this.Command @arguments
20+
}
21+
else {
22+
& $this.Command @arguments @parameters
23+
}
24+
25+

0 commit comments

Comments
 (0)