in Sources/ArgumentParser/Usage/DumpHelpGenerator.swift [88:120]
init(commandStack: [ParsableCommand.Type]) {
guard let command = commandStack.last else {
preconditionFailure("commandStack must not be empty")
}
let parents = commandStack.dropLast()
var superCommands = parents.map { $0._commandName }
if let superName = parents.first?.configuration._superCommandName {
superCommands.insert(superName, at: 0)
}
let defaultSubcommand = command.configuration.defaultSubcommand?
.configuration.commandName
let subcommands = command.configuration.subcommands
.map { subcommand -> CommandInfoV0 in
var commandStack = commandStack
commandStack.append(subcommand)
return CommandInfoV0(commandStack: commandStack)
}
let arguments = commandStack
.allArguments()
.mergingCompositeArguments()
.compactMap(ArgumentInfoV0.init)
self = CommandInfoV0(
superCommands: superCommands,
commandName: command._commandName,
abstract: command.configuration.abstract,
discussion: command.configuration.discussion,
defaultSubcommand: defaultSubcommand,
subcommands: subcommands,
arguments: arguments)
}