-
Notifications
You must be signed in to change notification settings - Fork 482
Added a feature to avoid linebreaks between option when displaying help #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,20 +183,20 @@ private static Result<IEnumerable<Token>, Error> Tokenize( | |
settings.EnableDashDash)(arguments, optionSpecs); | ||
} | ||
|
||
private static ParserResult<T> MakeParserResult<T>(ParserResult<T> parserResult, ParserSettings settings) | ||
private /*static*/ ParserResult<T> MakeParserResult<T>(ParserResult<T> parserResult, ParserSettings settings) | ||
{ | ||
return DisplayHelp( | ||
parserResult, | ||
settings.HelpWriter, | ||
settings.MaximumDisplayWidth); | ||
} | ||
|
||
private static ParserResult<T> DisplayHelp<T>(ParserResult<T> parserResult, TextWriter helpWriter, int maxDisplayWidth) | ||
private /*static*/ ParserResult<T> DisplayHelp<T>(ParserResult<T> parserResult, TextWriter helpWriter, int maxDisplayWidth) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to just remove the static modifier altogether. We can see the change in diffs. |
||
{ | ||
parserResult.WithNotParsed( | ||
errors => | ||
Maybe.Merge(errors.ToMaybe(), helpWriter.ToMaybe()) | ||
.Do((_, writer) => writer.Write(HelpText.AutoBuild(parserResult, maxDisplayWidth))) | ||
.Do((_, writer) => writer.Write(HelpText.AutoBuild(parserResult, settings, maxDisplayWidth))) | ||
); | ||
|
||
return parserResult; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,7 +315,7 @@ public void Invoke_AutoBuild_for_Options_returns_appropriate_formatted_text() | |
}); | ||
|
||
// Exercize system | ||
var helpText = HelpText.AutoBuild(fakeResult); | ||
var helpText = HelpText.AutoBuild(fakeResult, new ParserSettings()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these test updates should've alerted you to the fact that you broke the existing expected interface. This will cause problems for people simply upgrading from a patch release, we'd have to make it wait until a full version release. As noted elsewhere, you should preserve this method and make your new method an overload with the old method calling the new method with that default |
||
|
||
// Verify outcome | ||
var lines = helpText.ToString().ToNotEmptyLines().TrimStringArray(); | ||
|
@@ -350,7 +350,7 @@ public void Invoke_AutoBuild_for_Verbs_with_specific_verb_returns_appropriate_fo | |
}); | ||
|
||
// Exercize system | ||
var helpText = HelpText.AutoBuild(fakeResult); | ||
var helpText = HelpText.AutoBuild(fakeResult, new ParserSettings()); | ||
|
||
// Verify outcome | ||
var lines = helpText.ToString().ToNotEmptyLines().TrimStringArray(); | ||
|
@@ -383,7 +383,7 @@ public void Invoke_AutoBuild_for_Verbs_with_specific_verb_returns_appropriate_fo | |
}); | ||
|
||
// Exercize system | ||
var helpText = HelpText.AutoBuild(fakeResult, maxDisplayWidth: 100); | ||
var helpText = HelpText.AutoBuild(fakeResult, new ParserSettings(), maxDisplayWidth: 100); | ||
|
||
// Verify outcome | ||
var lines = helpText.ToString().ToNotEmptyLines().TrimStringArray(); | ||
|
@@ -415,7 +415,7 @@ public void Invoke_AutoBuild_for_Verbs_with_unknown_verb_returns_appropriate_for | |
new Error[] { new HelpVerbRequestedError(null, null, false) }); | ||
|
||
// Exercize system | ||
var helpText = HelpText.AutoBuild(fakeResult); | ||
var helpText = HelpText.AutoBuild(fakeResult, new ParserSettings()); | ||
|
||
// Verify outcome | ||
var lines = helpText.ToString().ToNotEmptyLines().TrimStringArray(); | ||
|
@@ -501,7 +501,7 @@ public void Invoke_AutoBuild_for_Options_with_Usage_returns_appropriate_formatte | |
}); | ||
|
||
// Exercize system | ||
var helpText = HelpText.AutoBuild(fakeResult); | ||
var helpText = HelpText.AutoBuild(fakeResult, new ParserSettings()); | ||
|
||
// Verify outcome | ||
var text = helpText.ToString(); | ||
|
@@ -554,7 +554,7 @@ public void Default_set_to_sequence_should_be_properly_printed() | |
|
||
// Exercize system | ||
handlers.ChangeCulture(); | ||
var helpText = HelpText.AutoBuild(fakeResult); | ||
var helpText = HelpText.AutoBuild(fakeResult, new ParserSettings()); | ||
handlers.ResetCulture(); | ||
|
||
// Verify outcome | ||
|
@@ -585,7 +585,7 @@ public void AutoBuild_when_no_assembly_attributes() | |
{ | ||
onErrorCalled = true; | ||
return ht; | ||
}, ex => ex); | ||
}, ex => ex, new ParserSettings()); | ||
|
||
onErrorCalled.Should().BeTrue(); | ||
actualResult.Copyright.Should().Be(expectedCopyright); | ||
|
@@ -617,7 +617,7 @@ public void AutoBuild_with_assembly_title_and_version_attributes_only() | |
{ | ||
onErrorCalled = true; | ||
return ht; | ||
}, ex => ex); | ||
}, ex => ex, new ParserSettings()); | ||
|
||
onErrorCalled.Should().BeTrue(); | ||
actualResult.Heading.Should().Be(string.Format("{0} {1}", expectedTitle, expectedVersion)); | ||
|
@@ -648,7 +648,7 @@ public void AutoBuild_with_assembly_company_attribute_only() | |
{ | ||
onErrorCalled = true; | ||
return ht; | ||
}, ex => ex); | ||
}, ex => ex, new ParserSettings()); | ||
|
||
onErrorCalled.Should().BeFalse(); // Other attributes have fallback logic | ||
actualResult.Copyright.Should().Be(string.Format("Copyright (C) {0} {1}", DateTime.Now.Year, expectedCompany)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to just remove the static modifier altogether. We can see the change in diffs.