diff --git a/src/UnionArgParser/UnParsers.fs b/src/UnionArgParser/UnParsers.fs
index 2362b0d0..bcf0bcea 100644
--- a/src/UnionArgParser/UnParsers.fs
+++ b/src/UnionArgParser/UnParsers.fs
@@ -98,6 +98,42 @@
args |> Seq.collect printEntry |> Seq.toArray
+ ///
+ /// print the command line syntax
+ ///
+ ///
+ let printCommandLineSyntax (argInfo : ArgInfo list) =
+ let sorted =
+ argInfo
+ |> List.filter (fun ai -> not ai.Hidden)
+ |> List.sortBy (fun ai -> not ai.IsFirst, ai.IsRest)
+
+ stringB {
+ for aI in sorted do
+ if not aI.Mandatory then yield "["
+ match aI.CommandLineNames with
+ | [] -> ()
+ | h :: t ->
+ if aI.Mandatory && not <| List.isEmpty t then yield "("
+ yield h
+ for n in t do
+ yield "|"
+ yield n
+ if aI.Mandatory && not <| List.isEmpty t then yield ")"
+
+ match aI.IsEqualsAssignment with
+ | true ->
+ yield sprintf "=<%O>" aI.FieldParsers.[0]
+ | false ->
+ for p in aI.FieldParsers do
+ yield sprintf " <%O>" p
+
+ if aI.IsRest then yield " ..."
+
+ if not aI.Mandatory then yield "]"
+ if aI.Id <> (Seq.last sorted).Id then yield " "
+ } |> String.build
+
///
/// returns an App.Config XElement given a set of config parameters
///
diff --git a/src/UnionArgParser/UnionArgParser.fs b/src/UnionArgParser/UnionArgParser.fs
index 87dfd9db..6bcb24ae 100644
--- a/src/UnionArgParser/UnionArgParser.fs
+++ b/src/UnionArgParser/UnionArgParser.fs
@@ -139,6 +139,10 @@
/// The message to be displayed on top of the usage string.
member __.Usage (?message : string) : string = printUsage message argInfo
+ /// Prints command line syntax. Useful for generating documentation.
+ member __.PrintCommandLineSyntax () : string =
+ printCommandLineSyntax argInfo
+
/// Prints parameters in command line format. Useful for argument string generation.
member __.PrintCommandLine (args : 'Template list) : string [] =
printCommandLineArgs argInfo args