Skip to content

Commit 7614a9f

Browse files
committed
Updated sample to include > 8 params
1 parent b58711e commit 7614a9f

File tree

2 files changed

+48
-22
lines changed

2 files changed

+48
-22
lines changed

src/TestConsole/ProgramExtraInputs.fs

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,50 @@ module ProgramExtraInputs
33

44
open FSharp.SystemCommandLine
55

6-
module Parameters =
7-
let words = Input.Option<string[]>(["--word"; "-w"], Array.empty, "A list of words to be appended")
8-
let separator = Input.OptionMaybe<string>(["--separator"; "-s"], "A character that will separate the joined words.")
6+
let a = Input.Option<string>("-a", defaultValue = "a?")
7+
let b = Input.Option<string>("-b", defaultValue = "b?")
8+
let c = Input.Option<string>("-c", defaultValue = "c?")
9+
let d = Input.Option<string>("-d", defaultValue = "d?")
10+
let e = Input.Option<string>("-e", defaultValue = "e?")
11+
let f = Input.Option<int>("-1", defaultValue = 0)
12+
let g = Input.Option<int>("-2", defaultValue = 0)
13+
let h = Input.Option<int>("-3", defaultValue = 0) // NOTE: "-h" is taken via Help pipeline defaults
14+
let i = Input.Option<int>("-4", defaultValue = 0)
15+
let j = Input.Option<int>("-5", defaultValue = 0)
916

1017
let app (ctx: System.CommandLine.Invocation.InvocationContext) =
11-
// Manually parse parameters
12-
let words = Parameters.words.GetValue ctx
13-
let separator = Parameters.separator.GetValue ctx
14-
15-
// Append words together
16-
let separator = separator |> Option.defaultValue ", "
17-
System.String.Join(separator, words) |> printfn "Result: %s"
18+
[
19+
a.GetValue ctx
20+
b.GetValue ctx
21+
c.GetValue ctx
22+
d.GetValue ctx
23+
e.GetValue ctx
24+
f.GetValue ctx |> string
25+
g.GetValue ctx |> string
26+
h.GetValue ctx |> string
27+
i.GetValue ctx |> string
28+
j.GetValue ctx |> string
29+
]
30+
|> String.concat ", "
31+
|> printfn "Result: %s"
1832
0
1933

20-
//[<EntryPoint>]
34+
[<EntryPoint>]
2135
let main argv =
2236
let ctx = Input.Context()
2337

2438
rootCommand argv {
2539
description "Appends words together"
2640
inputs ctx
2741
setHandler app
28-
add Parameters.words
29-
add Parameters.separator
42+
add a
43+
add b
44+
add c
45+
add d
46+
add e
47+
add f
48+
add g
49+
add h
50+
add i
51+
add j
3052
}
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
2-
"profiles": {
3-
"TestConsole": {
4-
"commandName": "Project",
5-
"commandLineArgs": "-w hello -w world"
6-
},
7-
"Leading @": {
8-
"commandName": "Project",
9-
"commandLineArgs": "--package @shoelace-style/shoelace"
2+
"profiles": {
3+
"TestConsole": {
4+
"commandName": "Project",
5+
"commandLineArgs": "-w hello -w world"
6+
},
7+
"GT8": {
8+
"commandName": "Project",
9+
"commandLineArgs": "-a A -b B -c C -d D -e E -1 1 -2 2 -3 3 -4 4 -5 5"
10+
},
11+
"Leading @": {
12+
"commandName": "Project",
13+
"commandLineArgs": "--package @shoelace-style/shoelace"
14+
}
1015
}
11-
}
1216
}

0 commit comments

Comments
 (0)