From 10c326a2f527fa296a4e2dca69c17c114e6359a5 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Tue, 8 Mar 2022 23:03:35 +0000 Subject: [PATCH] Update command.ps1 add hide member refactor setter --- lib/command.ps1 | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/command.ps1 b/lib/command.ps1 index 786e713..c936ffb 100644 --- a/lib/command.ps1 +++ b/lib/command.ps1 @@ -4,21 +4,33 @@ class Special { # Constructor Special() { - AddCommandMembers -PARAMS @('restart', 'shutdown', 'show') + AddActionMembers -PARAMS @('restart', 'shutdown', 'show') } - [String] Getter($param) { - return Write-Warning("ERROR: Usage: $param") + [Single] Getter($cmd) { + return Param_Get -PARAM $cmd -IS_STRING $false } - [void] Setter($param, $val = $true) { - Param_Set -PARAM $param -VALUE $(if ($val) {1} else {0}) - } + [void] Setter($param, $val) { + if ($val -is [Boolean]) { + Param_Set -PARAM $param -VALUE $(if ($val) {1} else {0}) + } + else { + Param_Set -PARAM $param -VALUE $val + } + } [String] cmd ($arg) { return "Command.$arg" } + hidden $_hide = $($this | Add-Member ScriptProperty 'hide' ` + { + $this._hide = $this.Setter($this.cmd('show'), $false) + }` + {} + ) + hidden $_showvbanchat = $($this | Add-Member ScriptProperty 'showvbanchat' ` { $this.Getter($this.cmd('DialogShow.VBANCHAT'))