Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/ArgumentParser/Usage/DumpHelpGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ fileprivate extension CommandInfoV0 {
self = CommandInfoV0(
superCommands: superCommands,
commandName: command._commandName,
shouldDisplay: command.configuration.shouldDisplay,
abstract: command.configuration.abstract,
discussion2: .init(command.configuration.discussion),
defaultSubcommand: defaultSubcommand,
Expand Down
12 changes: 9 additions & 3 deletions Sources/ArgumentParserToolInfo/ToolInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public struct CommandInfoV0: Codable, Hashable {
/// Custom CodingKeys names.
enum CodingKeys: String, CodingKey {
case discussion2 = "discussion"
case superCommands, commandName, abstract, defaultSubcommand, subcommands, arguments
case superCommands, commandName, abstract, defaultSubcommand, subcommands, arguments, shouldDisplay
}

/// Super commands and tools.
Expand Down Expand Up @@ -143,6 +143,9 @@ public struct CommandInfoV0: Codable, Hashable {
/// for a custom `CaseIterable` type), or can describe
/// a static block of text that extends the description of the argument.
public var discussion2: Discussion?

/// Command should appear in help displays.
public var shouldDisplay: Bool = true

/// Optional name of the subcommand invoked when the command is invoked with
/// no arguments.
Expand All @@ -155,6 +158,7 @@ public struct CommandInfoV0: Codable, Hashable {
public init(
superCommands: [String],
commandName: String,
shouldDisplay: Bool,
abstract: String,
discussion2: Discussion?,
defaultSubcommand: String?,
Expand All @@ -164,6 +168,7 @@ public struct CommandInfoV0: Codable, Hashable {
self.superCommands = superCommands.nonEmpty

self.commandName = commandName
self.shouldDisplay = shouldDisplay
self.abstract = abstract.nonEmpty
self.discussion2 = discussion2
self.defaultSubcommand = defaultSubcommand?.nonEmpty
Expand All @@ -186,6 +191,7 @@ public struct CommandInfoV0: Codable, Hashable {
self.init(
superCommands: superCommands,
commandName: commandName,
shouldDisplay: true,
abstract: abstract,
discussion2: discussion,
defaultSubcommand: defaultSubcommand,
Expand Down Expand Up @@ -244,7 +250,7 @@ public struct ArgumentInfoV0: Codable, Hashable {
public var shouldDisplay: Bool
/// Custom name of argument's section.
public var sectionTitle: String?

/// Argument can be omitted.
public var isOptional: Bool
/// Argument can be specified multiple times.
Expand Down Expand Up @@ -311,7 +317,7 @@ public struct ArgumentInfoV0: Codable, Hashable {

self.shouldDisplay = shouldDisplay
self.sectionTitle = sectionTitle

self.isOptional = isOptional
self.isRepeating = isRepeating

Expand Down
24 changes: 21 additions & 3 deletions Tests/ArgumentParserUnitTests/DumpHelpGenerationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ extension DumpHelpGenerationTests {

@Option(help: .init(discussion: "A discussion."))
var discussion: String

static var configuration = CommandConfiguration(shouldDisplay: false)
}

public func testDumpA() throws {
Expand Down Expand Up @@ -277,7 +279,8 @@ extension DumpHelpGenerationTests {
"valueName" : "help"
}
],
"commandName" : "a"
"commandName" : "a",
"shouldDisplay" : true
},
"serializationVersion" : 0
}
Expand Down Expand Up @@ -346,7 +349,8 @@ extension DumpHelpGenerationTests {
"valueName" : "help"
}
],
"commandName" : "b"
"commandName" : "b",
"shouldDisplay" : true
},
"serializationVersion" : 0
}
Expand Down Expand Up @@ -594,7 +598,8 @@ extension DumpHelpGenerationTests {
"valueName" : "help"
}
],
"commandName" : "c"
"commandName" : "c",
"shouldDisplay" : false
},
"serializationVersion" : 0
}
Expand Down Expand Up @@ -647,6 +652,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "math",
"shouldDisplay" : true,
"subcommands" : [
{
"abstract" : "Print the sum of the values.",
Expand Down Expand Up @@ -723,6 +729,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "add",
"shouldDisplay" : true,
"superCommands" : [
"math"
]
Expand Down Expand Up @@ -802,6 +809,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "multiply",
"shouldDisplay" : true,
"superCommands" : [
"math"
]
Expand Down Expand Up @@ -851,6 +859,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "stats",
"shouldDisplay" : true,
"subcommands" : [
{
"abstract" : "Print the average of the values.",
Expand Down Expand Up @@ -929,6 +938,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "average",
"shouldDisplay" : true,
"superCommands" : [
"math",
"stats"
Expand Down Expand Up @@ -987,6 +997,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "stdev",
"shouldDisplay" : true,
"superCommands" : [
"math",
"stats"
Expand Down Expand Up @@ -1195,6 +1206,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "quantiles",
"shouldDisplay" : true,
"superCommands" : [
"math",
"stats"
Expand Down Expand Up @@ -1289,6 +1301,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "add",
"shouldDisplay" : true,
"superCommands" : [
"math"
]
Expand Down Expand Up @@ -1375,6 +1388,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "multiply",
"shouldDisplay" : true,
"superCommands" : [
"math"
]
Expand Down Expand Up @@ -1431,6 +1445,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "stats",
"shouldDisplay" : true,
"subcommands" : [
{
"abstract" : "Print the average of the values.",
Expand Down Expand Up @@ -1509,6 +1524,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "average",
"shouldDisplay" : true,
"superCommands" : [
"math",
"stats"
Expand Down Expand Up @@ -1567,6 +1583,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "stdev",
"shouldDisplay" : true,
"superCommands" : [
"math",
"stats"
Expand Down Expand Up @@ -1775,6 +1792,7 @@ extension DumpHelpGenerationTests {
}
],
"commandName" : "quantiles",
"shouldDisplay" : true,
"superCommands" : [
"math",
"stats"
Expand Down