diff --git a/Sources/ArgumentParser/Usage/DumpHelpGenerator.swift b/Sources/ArgumentParser/Usage/DumpHelpGenerator.swift index 3ed2ac260..c1b9feb17 100644 --- a/Sources/ArgumentParser/Usage/DumpHelpGenerator.swift +++ b/Sources/ArgumentParser/Usage/DumpHelpGenerator.swift @@ -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, diff --git a/Sources/ArgumentParserToolInfo/ToolInfo.swift b/Sources/ArgumentParserToolInfo/ToolInfo.swift index d4b8efaf9..35fe28a81 100644 --- a/Sources/ArgumentParserToolInfo/ToolInfo.swift +++ b/Sources/ArgumentParserToolInfo/ToolInfo.swift @@ -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. @@ -66,6 +68,7 @@ public struct CommandInfoV0: Codable, Hashable { superCommands: [String], shouldDisplay: Bool, commandName: String, + aliases: [String]?, abstract: String, discussion: String, defaultSubcommand: String?, @@ -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 @@ -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( diff --git a/Tests/ArgumentParserToolInfoTests/Examples/example1.json b/Tests/ArgumentParserToolInfoTests/Examples/example1.json index 43ae9b1e5..892372210 100644 --- a/Tests/ArgumentParserToolInfoTests/Examples/example1.json +++ b/Tests/ArgumentParserToolInfoTests/Examples/example1.json @@ -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": [ @@ -63,6 +69,6 @@ "isRepeating": false, "parsingStrategy" : "default", } - ] + ], } } diff --git a/Tests/ArgumentParserUnitTests/Snapshots/testADumpHelp().json b/Tests/ArgumentParserUnitTests/Snapshots/testADumpHelp().json index cb981545d..fcc628d7e 100644 --- a/Tests/ArgumentParserUnitTests/Snapshots/testADumpHelp().json +++ b/Tests/ArgumentParserUnitTests/Snapshots/testADumpHelp().json @@ -1,5 +1,8 @@ { "command" : { + "aliases" : [ + + ], "arguments" : [ { "allValues" : [ @@ -179,6 +182,9 @@ "subcommands" : [ { "abstract" : "Show subcommand help information.", + "aliases" : [ + + ], "arguments" : [ { "isOptional" : true, diff --git a/Tests/ArgumentParserUnitTests/Snapshots/testBDumpHelp().json b/Tests/ArgumentParserUnitTests/Snapshots/testBDumpHelp().json index 5b584df63..9f8857e05 100644 --- a/Tests/ArgumentParserUnitTests/Snapshots/testBDumpHelp().json +++ b/Tests/ArgumentParserUnitTests/Snapshots/testBDumpHelp().json @@ -1,5 +1,8 @@ { "command" : { + "aliases" : [ + + ], "arguments" : [ { "isOptional" : true, @@ -68,6 +71,9 @@ "subcommands" : [ { "abstract" : "Show subcommand help information.", + "aliases" : [ + + ], "arguments" : [ { "isOptional" : true, diff --git a/Tests/ArgumentParserUnitTests/Snapshots/testCDumpHelp().json b/Tests/ArgumentParserUnitTests/Snapshots/testCDumpHelp().json index 7cbcafeea..cb4f9e2a3 100644 --- a/Tests/ArgumentParserUnitTests/Snapshots/testCDumpHelp().json +++ b/Tests/ArgumentParserUnitTests/Snapshots/testCDumpHelp().json @@ -1,5 +1,8 @@ { "command" : { + "aliases" : [ + + ], "arguments" : [ { "abstract" : "A color to select.", @@ -202,6 +205,9 @@ "subcommands" : [ { "abstract" : "Show subcommand help information.", + "aliases" : [ + + ], "arguments" : [ { "isOptional" : true, diff --git a/Tests/ArgumentParserUnitTests/Snapshots/testMathAddDumpHelp().json b/Tests/ArgumentParserUnitTests/Snapshots/testMathAddDumpHelp().json index 51568de7c..2b75babde 100644 --- a/Tests/ArgumentParserUnitTests/Snapshots/testMathAddDumpHelp().json +++ b/Tests/ArgumentParserUnitTests/Snapshots/testMathAddDumpHelp().json @@ -1,6 +1,9 @@ { "command" : { "abstract" : "Print the sum of the values.", + "aliases" : [ + + ], "arguments" : [ { "abstract" : "Use hexadecimal notation for the result.", @@ -82,6 +85,9 @@ "subcommands" : [ { "abstract" : "Show subcommand help information.", + "aliases" : [ + + ], "arguments" : [ { "isOptional" : true, diff --git a/Tests/ArgumentParserUnitTests/Snapshots/testMathDumpHelp().json b/Tests/ArgumentParserUnitTests/Snapshots/testMathDumpHelp().json index 01e3b89ee..2b885d7d3 100644 --- a/Tests/ArgumentParserUnitTests/Snapshots/testMathDumpHelp().json +++ b/Tests/ArgumentParserUnitTests/Snapshots/testMathDumpHelp().json @@ -1,6 +1,9 @@ { "command" : { "abstract" : "A utility for performing maths.", + "aliases" : [ + + ], "arguments" : [ { "abstract" : "Show the version.", @@ -50,6 +53,9 @@ "subcommands" : [ { "abstract" : "Print the sum of the values.", + "aliases" : [ + + ], "arguments" : [ { "abstract" : "Use hexadecimal notation for the result.", @@ -134,6 +140,9 @@ }, { "abstract" : "Print the product of the values.", + "aliases" : [ + "mul" + ], "arguments" : [ { "abstract" : "Use hexadecimal notation for the result.", @@ -218,6 +227,9 @@ }, { "abstract" : "Calculate descriptive statistics.", + "aliases" : [ + + ], "arguments" : [ { "abstract" : "Show the version.", @@ -267,6 +279,9 @@ "subcommands" : [ { "abstract" : "Print the average of the values.", + "aliases" : [ + "avg" + ], "arguments" : [ { "abstract" : "The kind of average to provide.", @@ -363,6 +378,9 @@ }, { "abstract" : "Print the standard deviation of the values.", + "aliases" : [ + + ], "arguments" : [ { "abstract" : "A group of floating-point values to operate on.", @@ -425,6 +443,9 @@ }, { "abstract" : "Print the quantiles of the values (TBD).", + "aliases" : [ + + ], "arguments" : [ { "completionKind" : { @@ -726,6 +747,9 @@ }, { "abstract" : "Show subcommand help information.", + "aliases" : [ + + ], "arguments" : [ { "isOptional" : true, diff --git a/Tests/ArgumentParserUnitTests/Snapshots/testMathMultiplyDumpHelp().json b/Tests/ArgumentParserUnitTests/Snapshots/testMathMultiplyDumpHelp().json index 7494decf6..aa95b3a75 100644 --- a/Tests/ArgumentParserUnitTests/Snapshots/testMathMultiplyDumpHelp().json +++ b/Tests/ArgumentParserUnitTests/Snapshots/testMathMultiplyDumpHelp().json @@ -1,6 +1,9 @@ { "command" : { "abstract" : "Print the product of the values.", + "aliases" : [ + "mul" + ], "arguments" : [ { "abstract" : "Use hexadecimal notation for the result.", @@ -82,6 +85,9 @@ "subcommands" : [ { "abstract" : "Show subcommand help information.", + "aliases" : [ + + ], "arguments" : [ { "isOptional" : true, diff --git a/Tests/ArgumentParserUnitTests/Snapshots/testMathStatsDumpHelp().json b/Tests/ArgumentParserUnitTests/Snapshots/testMathStatsDumpHelp().json index 725c51f63..d719e02ca 100644 --- a/Tests/ArgumentParserUnitTests/Snapshots/testMathStatsDumpHelp().json +++ b/Tests/ArgumentParserUnitTests/Snapshots/testMathStatsDumpHelp().json @@ -1,6 +1,9 @@ { "command" : { "abstract" : "Calculate descriptive statistics.", + "aliases" : [ + + ], "arguments" : [ { "abstract" : "Show the version.", @@ -50,6 +53,9 @@ "subcommands" : [ { "abstract" : "Print the average of the values.", + "aliases" : [ + "avg" + ], "arguments" : [ { "abstract" : "The kind of average to provide.", @@ -146,6 +152,9 @@ }, { "abstract" : "Print the standard deviation of the values.", + "aliases" : [ + + ], "arguments" : [ { "abstract" : "A group of floating-point values to operate on.", @@ -208,6 +217,9 @@ }, { "abstract" : "Print the quantiles of the values (TBD).", + "aliases" : [ + + ], "arguments" : [ { "completionKind" : { @@ -504,6 +516,9 @@ }, { "abstract" : "Show subcommand help information.", + "aliases" : [ + + ], "arguments" : [ { "isOptional" : true,