Skip to content

Commit d87f697

Browse files
author
James Brundage
committed
UDP Protocol: Fixing help and improving validation (Fixes #282)
1 parent 5626ebc commit d87f697

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Transpilers/Protocols/UDP.Protocol.psx.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using namespace System.Management.Automation.Language;
21
<#
32
.SYNOPSIS
43
udp protocol
@@ -7,7 +6,7 @@ using namespace System.Management.Automation.Language;
76
.EXAMPLE
87
udp://127.0.0.1:8568 # Creates a UDP Client
98
.EXAMPLE
10-
udp:// -Host [ipaddress]::broadcast 911 -Send "It's an emergency!"
9+
udp:// -Host [ipaddress]::broadcast -port 911 -Send "It's an emergency!"
1110
.EXAMPLE
1211
{send udp:// -Host [ipaddress]::broadcast -Port 911 "It's an emergency!"}.Transpile()
1312
.EXAMPLE
@@ -17,11 +16,19 @@ using namespace System.Management.Automation.Language;
1716
1817
Invoke-PipeScript { receive udp://*:911 -Keep }
1918
#>
19+
using namespace System.Management.Automation.Language
20+
2021
[ValidateScript({
2122
$commandAst = $_
2223
if ($commandAst.CommandElements[0..1] -match '^udp://' -ne $null) {
24+
if ($commandAst.CommandElements[0] -notmatch '^udp://') {
25+
if ($commandAst.CommandElements[0].value -notin 'send', 'receive') {
26+
return $false
27+
}
28+
}
2329
return $true
2430
}
31+
2532
return $false
2633
})]
2734
param(

0 commit comments

Comments
 (0)