Skip to content

Commit e251d25

Browse files
authored
Merge pull request #18 from MinoruSekine/feat/17/version
feat: Support `-Version` and `-?` options. (#17)
2 parents ed446a1 + b1c262a commit e251d25

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

toast-cli.ps1

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,21 @@
1616
# You should have received a copy of the GNU Affero General Public License
1717
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1818

19+
[CmdletBinding()]
1920
param (
20-
[parameter(mandatory=$true)][string]$body,
21-
[parameter(mandatory=$false)][string]$title,
22-
[parameter(mandatory=$false)][string]$detail
21+
[string]$body,
22+
[string]$title,
23+
[string]$detail,
24+
[switch]$version
2325
)
2426

27+
$ToastCliVersion = '0.0.1'
28+
2529
function Show-Toast {
2630
param (
27-
[parameter(mandatory=$false)][string]$title,
28-
[parameter(mandatory=$false)][string]$message,
29-
[parameter(mandatory=$false)][string]$detail
31+
[Parameter(Mandatory = $false)][string]$title,
32+
[Parameter(Mandatory = $false)][string]$message,
33+
[Parameter(Mandatory = $false)][string]$detail
3034
)
3135

3236
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
@@ -52,4 +56,15 @@ function Show-Toast {
5256
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app_id).Show($toast)
5357
}
5458

55-
Show-Toast -title $title -message $body -detail $detail
59+
if ($version) {
60+
Write-Output "$($MyInvocation.MyCommand.Name) $ToastCliVersion"
61+
} else {
62+
if ($body) {
63+
Show-Toast -title $title -message $body -detail $detail
64+
} else {
65+
Write-Error "Missing required argument: -Body. See -? for usage."
66+
exit 1
67+
}
68+
}
69+
70+
exit 0

0 commit comments

Comments
 (0)