diff --git a/Sources/ArgumentParser/Usage/DumpHelpGenerator.swift b/Sources/ArgumentParser/Usage/DumpHelpGenerator.swift index 2f02b5e7f..27c301888 100644 --- a/Sources/ArgumentParser/Usage/DumpHelpGenerator.swift +++ b/Sources/ArgumentParser/Usage/DumpHelpGenerator.swift @@ -126,7 +126,7 @@ fileprivate extension ArgumentInfoV0 { self.init( kind: kind, shouldDisplay: argument.help.visibility.base == .default, - sectionTitle: argument.help.parentTitle.nilIfEmpty, + sectionTitle: argument.help.parentTitle.nonEmpty, isOptional: argument.help.options.contains(.isOptional), isRepeating: argument.help.options.contains(.isRepeating), names: argument.names.map(ArgumentInfoV0.NameInfoV0.init), diff --git a/Sources/ArgumentParser/Utilities/StringExtensions.swift b/Sources/ArgumentParser/Utilities/StringExtensions.swift index b49abe8ba..dba3b3594 100644 --- a/Sources/ArgumentParser/Utilities/StringExtensions.swift +++ b/Sources/ArgumentParser/Utilities/StringExtensions.swift @@ -239,7 +239,7 @@ extension StringProtocol where SubSequence == Substring { return "\(lines[0])\n\(lines[1].indentingEachLine(by: n))" } - var nilIfEmpty: Self? { + fileprivate var nonEmpty: Self? { isEmpty ? nil : self } }