Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriktsarpalis committed Jul 8, 2016
1 parent b490b4b commit 5d888d1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 3.1.0
* Add support for MainCommand attribute.

### 3.0.1
* Bugfix usage string rendering issue where description might span multiple lines.

Expand Down
31 changes: 31 additions & 0 deletions docs/content/tutorial.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,37 @@ Arguments can specify the following primitives as parameters:
* `System.Numerics.BigInt`.
* `byte[]`, which accepts base64 representations.
## Main commands
Arguments carrying the [MainCommand](reference/argu-arguattributes-maincommandattribute.html)
attribute can be used to specify the main set of arguments for the CLI.
These arguments can be passed without the need to specify a switch identifier.
*)

type WGetArguments =
| Quiet
| No_Check_Certificate
| [<MainCommand; ExactlyOnce; Last>] Urls of url:string list

(**
which generates the syntax
[lang=console]
USAGE: fsianycpu.exe [--help] [--quiet] [--no-check-certificate] <url>...
URLS:
<url>... List of urls to download from.
OPTIONS:
--quiet Turn off Wget's output.
--no-check-certificate
Don't check the server certificate.
--help display this list of options.
## Optional and List parameters
Additionally, it is possible to specify argument parameters that are either optional or lists:
Expand Down
13 changes: 3 additions & 10 deletions src/Argu/PreCompute.fs
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,8 @@ let rec private preComputeUnionCaseArgInfo (stack : Type list) (helpParam : Help

// extract the description string for given union case
let description =
try dummy.Usage.Split([|'\n'|], StringSplitOptions.RemoveEmptyEntries) |> Array.toList
with _ ->
arguExn "Error generating usage string from IArgParserTemplate for case %O." uci

if List.isEmpty description then
arguExn "Usage string for case '%O' was empty." uci
try dummy.Usage.Split('\n') |> Array.toList
with _ -> arguExn "Error generating usage string from IArgParserTemplate for case %O." uci

let uai = {
UnionCaseInfo = uci
Expand Down Expand Up @@ -464,10 +460,7 @@ and private preComputeUnionArgInfoInner (stack : Type list) (helpParam : HelpPar
let description =
match t.TryGetAttribute<HelpDescriptionAttribute> () with
| None -> [defaultHelpDescription]
| Some attr ->
match attr.Description.Split([|'\n'|], StringSplitOptions.RemoveEmptyEntries) with
| [||] -> arguExn "Text defined in HelpDescriptionAttribute was empty."
| descr -> Array.toList descr
| Some attr -> attr.Description.Split('\n') |> Array.toList

{ Flags = helpSwitches ; Description = description }

Expand Down

0 comments on commit 5d888d1

Please sign in to comment.