In a cake build script there is a very neat way of documenting the tasks using the .Description() extension on the Task. These descriptions are displayed when calling the build script with the -showdescription argument.
I have several custom arguments in my build script that I'd like to document somehow. Currently I added a task that outputs a description text similar to the manual page style for the available arguments that looks something like this:
var nextLineDescription = "\n\t\t\t\t\t"; // for formatting
Console.WriteLine("ARGUMENTS");
Console.WriteLine("");
Console.WriteLine("\t--someparameter=<number>\t\t" +
"Description of the parameter" + nextLineDescription +
"that can span multiple lines" + nextLineDescription +
"and defaults to 5.\n");
This works fine but is a lot of work, especially if the text should be properly formatted so it's readable in the command line.
So when I call ./build.ps1 -Target MyDocTask
I get a nice result:
ARGUMENTS
--someparameter=number Description of the parameter
that can span multiple lines
and defaults to 5
--nextParameter Next description
...
Is there another way or a best practice to add documentation for arguments so it can be displayed in the command line similar to the tasks descriptions?
Edit: Alternatively, can I find all available parameters in my build script to loop over them and generate such a description instead of writing it manually for each parameter?