回答編集履歴
8
コード修正
test
CHANGED
@@ -28,7 +28,9 @@
|
|
28
28
|
|
29
29
|
[string]$Default = $null,
|
30
30
|
|
31
|
-
[parameter(Mandatory = $true, Position = 0)]
|
31
|
+
[parameter(Mandatory = $true, Position = 0)]
|
32
|
+
|
33
|
+
[System.Collections.IDictionary]$Selections
|
32
34
|
|
33
35
|
)
|
34
36
|
|
7
コード修正
test
CHANGED
@@ -18,45 +18,45 @@
|
|
18
18
|
|
19
19
|
```PowerShell
|
20
20
|
|
21
|
-
function Choice
|
21
|
+
function Choice {
|
22
|
-
|
23
|
-
{
|
24
22
|
|
25
23
|
param (
|
26
24
|
|
27
25
|
[string]$Title = $null,
|
28
26
|
|
29
|
-
[string]$Message = "
|
27
|
+
[string]$Message = "",
|
30
28
|
|
31
29
|
[string]$Default = $null,
|
32
30
|
|
33
|
-
[parameter(Mandatory=$true, Position=0)][System.Collections.IDictionary]$Selections
|
31
|
+
[parameter(Mandatory = $true, Position = 0)][System.Collections.IDictionary]$Selections
|
34
32
|
|
35
33
|
)
|
36
34
|
|
37
35
|
|
38
36
|
|
37
|
+
if ($Message -eq "" -and (-not $Default)) { $Message = " " }
|
38
|
+
|
39
|
-
if($Title) { Write-Host $Title }
|
39
|
+
if ($Title) { Write-Host $Title }
|
40
40
|
|
41
41
|
do {
|
42
42
|
|
43
43
|
$Selections.GetEnumerator() |
|
44
44
|
|
45
|
-
ForEach-Object { Write-Host ("
|
45
|
+
ForEach-Object { Write-Host ("[{0}] {1}" -f $_.key, $_.Value) `
|
46
46
|
|
47
|
-
-ForegroundColor $(if($_.Key -eq $Default) {
|
47
|
+
-ForegroundColor $(if ($_.Key -eq $Default) {"Yellow"} else {"White"}) }
|
48
48
|
|
49
|
+
|
49
50
|
|
51
|
+
$result = Read-Host ("{0}{1}" -f $Message, $(if ($Default) {"(規定値は'$Default')"}))
|
50
52
|
|
51
|
-
$result
|
53
|
+
if ($result -eq "") { $result = $Default }
|
52
54
|
|
53
|
-
|
55
|
+
} while ($result -notin $Selections.Keys)
|
54
56
|
|
55
|
-
|
57
|
+
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
$result
|
60
60
|
|
61
61
|
}
|
62
62
|
|
6
コード修正
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
[string]$Default = $null,
|
32
32
|
|
33
|
-
[parameter(Mandatory=$true, Position
|
33
|
+
[parameter(Mandatory=$true, Position=0)][System.Collections.IDictionary]$Selections
|
34
34
|
|
35
35
|
)
|
36
36
|
|
5
コード修正
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
[string]$Default = $null,
|
32
32
|
|
33
|
-
[parameter(Mandatory=$true)][System.Collections.IDictionary]$Selections
|
33
|
+
[parameter(Mandatory=$true, Position = 0)][System.Collections.IDictionary]$Selections
|
34
34
|
|
35
35
|
)
|
36
36
|
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
$selections = [Ordered]@{ 1 = "通常処理を行う。"; 2 = "処理1を挟む"; 3 = "処理1のみで終了させる。"; 4 = "終了する。" }
|
72
72
|
|
73
|
-
$ans = Choice -Title "-Menu-" -Message "番号を選択してください"
|
73
|
+
$ans = Choice -Title "-Menu-" -Message "番号を選択してください" $selections -Default 4
|
74
74
|
|
75
75
|
```
|
76
76
|
|
4
コード修正
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
```PowerShell
|
20
20
|
|
21
|
-
|
21
|
+
function Choice
|
22
22
|
|
23
23
|
{
|
24
24
|
|
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
if($Title) { Write-Host $Title }
|
40
40
|
|
41
|
-
|
41
|
+
do {
|
42
42
|
|
43
43
|
$Selections.GetEnumerator() |
|
44
44
|
|
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
if($result -eq '') { $result = $Default }
|
54
54
|
|
55
|
-
}
|
55
|
+
} while($result -notin $Selections.Keys)
|
56
56
|
|
57
57
|
|
58
58
|
|
3
コード修正
test
CHANGED
@@ -48,7 +48,7 @@
|
|
48
48
|
|
49
49
|
|
50
50
|
|
51
|
-
$result = Read-Host $Message $(if($Default) {
|
51
|
+
$result = Read-Host $Message $(if($Default) {"(規定値は'$Default')"})
|
52
52
|
|
53
53
|
if($result -eq '') { $result = $Default }
|
54
54
|
|
2
コード修正
test
CHANGED
@@ -36,23 +36,19 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
$
|
39
|
+
if($Title) { Write-Host $Title }
|
40
40
|
|
41
|
-
|
41
|
+
Do {
|
42
42
|
|
43
|
-
|
43
|
+
$Selections.GetEnumerator() |
|
44
|
+
|
45
|
+
ForEach-Object { Write-Host ("`[" + $_.Key + "`] " + $_.Value) `
|
46
|
+
|
47
|
+
-ForegroundColor $(if($_.Key -eq $Default) {'Yellow'} else {'White'}) }
|
44
48
|
|
45
49
|
|
46
50
|
|
47
|
-
|
51
|
+
$result = Read-Host $Message $(if($Default) { "(規定値は'$Default')" })
|
48
|
-
|
49
|
-
Do {
|
50
|
-
|
51
|
-
if($Title) { Write-Host $Title }
|
52
|
-
|
53
|
-
Write-Host $menu
|
54
|
-
|
55
|
-
$result = Read-Host $Message
|
56
52
|
|
57
53
|
if($result -eq '') { $result = $Default }
|
58
54
|
|
1
コード修正
test
CHANGED
@@ -54,7 +54,7 @@
|
|
54
54
|
|
55
55
|
$result = Read-Host $Message
|
56
56
|
|
57
|
-
if(
|
57
|
+
if($result -eq '') { $result = $Default }
|
58
58
|
|
59
59
|
} While($result -notin $Selections.Keys)
|
60
60
|
|