-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented a way to manually parse >8 inputs
- Loading branch information
1 parent
8f6f68b
commit bd53d14
Showing
6 changed files
with
75 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/// This option can be used when more than 8 inputs are required. | ||
module ProgramExtraInputs | ||
|
||
open FSharp.SystemCommandLine | ||
|
||
module Parameters = | ||
let words = Input.Option<string[]>(["--word"; "-w"], Array.empty, "A list of words to be appended") | ||
let separator = Input.OptionMaybe<string>(["--separator"; "-s"], "A character that will separate the joined words.") | ||
|
||
let app (ctx: System.CommandLine.Invocation.InvocationContext) = | ||
// Manually parse parameters | ||
let words = Parameters.words.GetValue ctx | ||
let separator = Parameters.separator.GetValue ctx | ||
|
||
// Append words together | ||
let separator = separator |> Option.defaultValue ", " | ||
System.String.Join(separator, words) |> printfn "Result: %s" | ||
0 | ||
|
||
//[<EntryPoint>] | ||
let main argv = | ||
let ctx = Input.Context() | ||
|
||
rootCommand argv { | ||
description "Appends words together" | ||
inputs ctx | ||
setHandler app | ||
add Parameters.words | ||
add Parameters.separator | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters