Skip to content

Commit a7fd065

Browse files
Initial implementation
1 parent 9dd1adb commit a7fd065

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

src/CommandLine/Text/CopyrightInfo.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
22

33
using System;
4+
using System.Dynamic;
45
using System.Globalization;
56
using System.Reflection;
67
using System.Text;
@@ -24,6 +25,17 @@ public class CopyrightInfo
2425
private readonly string author;
2526
private readonly int builderSize;
2627

28+
/// <summary>
29+
/// An empty object used for initialization.
30+
/// </summary>
31+
public static CopyrightInfo Empty
32+
{
33+
get
34+
{
35+
return new CopyrightInfo("author", 1);
36+
}
37+
}
38+
2739
/// <summary>
2840
/// Initializes a new instance of the <see cref="CommandLine.Text.CopyrightInfo"/> class
2941
/// specifying author and year.

src/CommandLine/Text/HeadingInfo.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ public HeadingInfo(string programName, string version = null)
3333
this.version = version;
3434
}
3535

36+
/// <summary>
37+
/// An empty object used for initialization.
38+
/// </summary>
39+
public static HeadingInfo Empty
40+
{
41+
get
42+
{
43+
return new HeadingInfo("");
44+
}
45+
}
46+
3647
/// <summary>
3748
/// Gets the default heading instance.
3849
/// The title is retrieved from <see cref="AssemblyTitleAttribute"/>,

src/CommandLine/Text/HelpText.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,23 @@ public static HelpText AutoBuild<T>(
212212
{
213213
var auto = new HelpText
214214
{
215-
Heading = HeadingInfo.Default,
216-
Copyright = CopyrightInfo.Default,
215+
Heading = HeadingInfo.Empty,
216+
Copyright = CopyrightInfo.Empty,
217217
AdditionalNewLineAfterOption = true,
218218
AddDashesToOption = !verbsIndex,
219219
MaximumDisplayWidth = maxDisplayWidth
220220
};
221221

222+
try
223+
{
224+
auto.Heading = HeadingInfo.Default;
225+
auto.Copyright = CopyrightInfo.Default;
226+
}
227+
catch (Exception)
228+
{
229+
auto = onError(auto);
230+
}
231+
222232
var errors = Enumerable.Empty<Error>();
223233

224234
if (onError != null && parserResult.Tag == ParserResultType.NotParsed)

0 commit comments

Comments
 (0)