Skip to content

Commit

Permalink
docs for args
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel committed Feb 12, 2022
1 parent 26df583 commit c0149eb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/FsAutoComplete/Options.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@ module Options =
type Rng = { File: string; Start: FSharp.Compiler.Text.pos; End: FSharp.Compiler.Text.pos }

let private setArity arity (o: #Option) = o.Arity <- arity; o
/// set option to expect no arguments (e.g a flag-style argument: `--verbose`)
let inline private zero x = setArity ArgumentArity.Zero x
/// set option to expect one argument (e.g a single value: `--foo bar)
let inline private one x = setArity ArgumentArity.ExactlyOne x
/// set option to expect multiple arguments
/// (e.g a list of values: `--foo bar baz` or `--foo bar --foo baz` depending on the style)
let inline private many x = setArity ArgumentArity.OneOrMore x

/// set option to allow multiple arguments per use of the option flag
/// (e.g. `--foo bar baz` is equivalent to `--foo bar --foo baz`)
let inline private multipleArgs (x: #Option) = x.AllowMultipleArgumentsPerToken <- true; x

let verboseOption =
Option<bool>([|"--verbose"; "-v"; "--debug"|], "Enable verbose logging. This is equivalent to --log debug.")
|> setArity ArgumentArity.Zero
Expand All @@ -40,8 +48,9 @@ module Options =
|> one

let logFilterOption =
Option<string[]>("--filter", "Filter logs by category. The category can be seen in the logs inside []. For example: [Compiler].")
Option<string[]>([|"--filter"; "--log-filter"|], "Filter logs by category. The category can be seen in the logs inside []. For example: [Compiler].")
|> many
|> fun o -> o.AllowMultipleArgumentsPerToken <- true; o

let waitForDebuggerOption =
Option<bool>("--wait-for-debugger", "Stop execution on startup until an external debugger to attach to this process")
Expand Down

0 comments on commit c0149eb

Please sign in to comment.