-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3-help.ps1
53 lines (45 loc) · 1.25 KB
/
3-help.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<#
.SYNOPSIS
This script is an example of how any .ps1 script can provide content to `Get-Help`.
.DESCRIPTION
USAGE
.\3-help.ps1 <command>
COMMANDS
up run `docker-compose up`
down run `docker-compose down`
build run `dotnet build`
test run `dotnet test`
ip get your local ip
help, -? show this help message
.LINK
https://kevinareed.com/2021/04/14/creating-a-command-based-cli-in-powershell/
#>
param(
[Parameter(Position=0)]
[ValidateSet("up", "down", "build", "test", "ip", "help")]
# The command to run
[string]$Command
)
function Command-Help { Get-Help $PSCommandPath }
if (!$Command) {
Command-Help
exit
}
function Command-Up { iex "docker compose up" }
function Command-Down { iex "docker compose down" }
function Command-Build { iex "dotnet build" }
function Command-Test { iex "dotnet test" }
function Command-Ip {
$ip = iwr "https://api.ip.sb/ip" `
| Select-Object -Expand Content
Write-Host "Your IP address is: " -N
Write-Host $ip -F Green
}
switch ($Command) {
"up" { Command-Up }
"down" { Command-Down }
"build" { Command-Build }
"test" { Command-Test }
"ip" { Command-Ip }
"help" { Command-Help }
}