Skip to content

Commit 8ec20bc

Browse files
authored
Merge pull request #24 from mrboring-forks/main
Added HelpName and AcceptLegalFilePathsOnly
2 parents aa1df1b + 999c313 commit 8ec20bc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ The new `Input` module contains functions for the underlying System.CommandLine
7272
* `optionMaybe` creates a named `Option<'T option>` that defaults to `None`.
7373

7474
### Input Properties
75+
* `acceptLegalFilePathsOnly` sets the option or argument to accept only values representing legal file paths.
7576
* `alias` adds an `Alias` to an `Option`
7677
* `aliases` adds one or more aliases to an `Option`
7778
* `desc` adds a description to an `Option` or `Argument`
7879
* `defaultValue` or `def` provides a default value to an `Option` or `Argument`
7980
* `defFactory` assigns a default value factor to an `Option` or `Argument`
81+
* `helpName` adds the name used in help output to describe the option or argument.
8082
* `required` marks an `Option` as required
8183
* `validate` allows you to return a `Result<unit, string>` for the parsed value
8284
* `validateFileExists` ensures that the `FileInfo` exists

src/FSharp.SystemCommandLine/Inputs.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ module Input =
6868
| _ -> ()
6969
input
7070

71+
/// Configures the option or argument to accept only values representing legal file paths.
72+
let acceptLegalFilePathsOnly (input: ActionInput<'T>) =
73+
input
74+
|> editOption (fun o -> o.AcceptLegalFilePathsOnly() |> ignore)
75+
|> editArgument (fun a -> a.AcceptLegalFilePathsOnly() |> ignore)
76+
7177
/// Adds one or more aliases to an option.
7278
let aliases (aliases: string seq) (input: ActionInput<'T>) =
7379
input |> editOption (fun o -> aliases |> Seq.iter o.Aliases.Add)
@@ -100,6 +106,12 @@ module Input =
100106
|> editOption (fun o -> o.DefaultValueFactory <- defaultValueFactory)
101107
|> editArgument (fun a -> a.DefaultValueFactory <- defaultValueFactory)
102108

109+
/// The name used in help output to describe the option or argument.
110+
let helpName (helpName: string) (input: ActionInput<'T>) =
111+
input
112+
|> editOption (fun o -> o.HelpName <- helpName)
113+
|> editArgument (fun a -> a.HelpName <- helpName)
114+
103115
/// Marks an option as required.
104116
let required (input: ActionInput<'T>) =
105117
input |> editOption (fun o -> o.Required <- true)

0 commit comments

Comments
 (0)