Skip to content
Open
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 @@ -87,6 +87,7 @@ extension CommandInfoV0 {
superCommands: superCommands,
shouldDisplay: command.configuration.shouldDisplay,
commandName: command._commandName,
aliases: command.configuration.aliases,
abstract: command.configuration.abstract,
discussion: command.configuration.discussion,
defaultSubcommand: defaultSubcommand,
Expand Down
6 changes: 6 additions & 0 deletions Sources/ArgumentParserToolInfo/ToolInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public struct CommandInfoV0: Codable, Hashable {

/// Name used to invoke the command.
public var commandName: String
/// List of command aliases.
public var aliases: [String]?
/// Short description of the command's functionality.
public var abstract: String?
/// Extended description of the command's functionality.
Expand All @@ -66,6 +68,7 @@ public struct CommandInfoV0: Codable, Hashable {
superCommands: [String],
shouldDisplay: Bool,
commandName: String,
aliases: [String]?,
abstract: String,
discussion: String,
defaultSubcommand: String?,
Expand All @@ -76,6 +79,7 @@ public struct CommandInfoV0: Codable, Hashable {
self.shouldDisplay = shouldDisplay

self.commandName = commandName
self.aliases = aliases
self.abstract = abstract.nonEmpty
self.discussion = discussion.nonEmpty

Expand All @@ -89,6 +93,8 @@ public struct CommandInfoV0: Codable, Hashable {
self.superCommands = try container.decodeIfPresent(
[String].self, forKey: .superCommands)
self.commandName = try container.decode(String.self, forKey: .commandName)
self.aliases = try container.decodeIfPresent(
[String].self, forKey: .aliases)
self.abstract = try container.decodeIfPresent(
String.self, forKey: .abstract)
self.discussion = try container.decodeIfPresent(
Expand Down
10 changes: 8 additions & 2 deletions Tests/ArgumentParserToolInfoTests/Examples/example1.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
"parent1"
],
"commandName": "full-example",
"aliases": [

],
"abstract": "this command does everything",
"discussion": "like actually everything",
"defaultSubcommand": "do-thing",
"subcommands": [
{
"commandName": "sub"
"commandName": "sub",
"aliases": [

]
}
],
"arguments": [
Expand Down Expand Up @@ -63,6 +69,6 @@
"isRepeating": false,
"parsingStrategy" : "default",
}
]
],
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"command" : {
"aliases" : [

],
"arguments" : [
{
"allValues" : [
Expand Down Expand Up @@ -179,6 +182,9 @@
"subcommands" : [
{
"abstract" : "Show subcommand help information.",
"aliases" : [

],
"arguments" : [
{
"isOptional" : true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"command" : {
"aliases" : [

],
"arguments" : [
{
"isOptional" : true,
Expand Down Expand Up @@ -68,6 +71,9 @@
"subcommands" : [
{
"abstract" : "Show subcommand help information.",
"aliases" : [

],
"arguments" : [
{
"isOptional" : true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"command" : {
"aliases" : [

],
"arguments" : [
{
"abstract" : "A color to select.",
Expand Down Expand Up @@ -202,6 +205,9 @@
"subcommands" : [
{
"abstract" : "Show subcommand help information.",
"aliases" : [

],
"arguments" : [
{
"isOptional" : true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"command" : {
"abstract" : "Print the sum of the values.",
"aliases" : [

],
"arguments" : [
{
"abstract" : "Use hexadecimal notation for the result.",
Expand Down Expand Up @@ -82,6 +85,9 @@
"subcommands" : [
{
"abstract" : "Show subcommand help information.",
"aliases" : [

],
"arguments" : [
{
"isOptional" : true,
Expand Down
24 changes: 24 additions & 0 deletions Tests/ArgumentParserUnitTests/Snapshots/testMathDumpHelp().json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"command" : {
"abstract" : "A utility for performing maths.",
"aliases" : [

],
"arguments" : [
{
"abstract" : "Show the version.",
Expand Down Expand Up @@ -50,6 +53,9 @@
"subcommands" : [
{
"abstract" : "Print the sum of the values.",
"aliases" : [

],
"arguments" : [
{
"abstract" : "Use hexadecimal notation for the result.",
Expand Down Expand Up @@ -134,6 +140,9 @@
},
{
"abstract" : "Print the product of the values.",
"aliases" : [
"mul"
],
"arguments" : [
{
"abstract" : "Use hexadecimal notation for the result.",
Expand Down Expand Up @@ -218,6 +227,9 @@
},
{
"abstract" : "Calculate descriptive statistics.",
"aliases" : [

],
"arguments" : [
{
"abstract" : "Show the version.",
Expand Down Expand Up @@ -267,6 +279,9 @@
"subcommands" : [
{
"abstract" : "Print the average of the values.",
"aliases" : [
"avg"
],
"arguments" : [
{
"abstract" : "The kind of average to provide.",
Expand Down Expand Up @@ -363,6 +378,9 @@
},
{
"abstract" : "Print the standard deviation of the values.",
"aliases" : [

],
"arguments" : [
{
"abstract" : "A group of floating-point values to operate on.",
Expand Down Expand Up @@ -425,6 +443,9 @@
},
{
"abstract" : "Print the quantiles of the values (TBD).",
"aliases" : [

],
"arguments" : [
{
"completionKind" : {
Expand Down Expand Up @@ -726,6 +747,9 @@
},
{
"abstract" : "Show subcommand help information.",
"aliases" : [

],
"arguments" : [
{
"isOptional" : true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"command" : {
"abstract" : "Print the product of the values.",
"aliases" : [
"mul"
],
"arguments" : [
{
"abstract" : "Use hexadecimal notation for the result.",
Expand Down Expand Up @@ -82,6 +85,9 @@
"subcommands" : [
{
"abstract" : "Show subcommand help information.",
"aliases" : [

],
"arguments" : [
{
"isOptional" : true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"command" : {
"abstract" : "Calculate descriptive statistics.",
"aliases" : [

],
"arguments" : [
{
"abstract" : "Show the version.",
Expand Down Expand Up @@ -50,6 +53,9 @@
"subcommands" : [
{
"abstract" : "Print the average of the values.",
"aliases" : [
"avg"
],
"arguments" : [
{
"abstract" : "The kind of average to provide.",
Expand Down Expand Up @@ -146,6 +152,9 @@
},
{
"abstract" : "Print the standard deviation of the values.",
"aliases" : [

],
"arguments" : [
{
"abstract" : "A group of floating-point values to operate on.",
Expand Down Expand Up @@ -208,6 +217,9 @@
},
{
"abstract" : "Print the quantiles of the values (TBD).",
"aliases" : [

],
"arguments" : [
{
"completionKind" : {
Expand Down Expand Up @@ -504,6 +516,9 @@
},
{
"abstract" : "Show subcommand help information.",
"aliases" : [

],
"arguments" : [
{
"isOptional" : true,
Expand Down