in Sources/ArgumentParser/Usage/HelpGenerator.swift [92:123]
init(commandStack: [ParsableCommand.Type]) {
guard let currentCommand = commandStack.last else {
fatalError()
}
let currentArgSet = ArgumentSet(currentCommand)
self.commandStack = commandStack
// Build the tool name and subcommand name from the command configuration
var toolName = commandStack.map { $0._commandName }.joined(separator: " ")
if let superName = commandStack.first!.configuration._superCommandName {
toolName = "\(superName) \(toolName)"
}
var usage = UsageGenerator(toolName: toolName, definition: [currentArgSet]).synopsis
if !currentCommand.configuration.subcommands.isEmpty {
if usage.last != " " { usage += " " }
usage += "<subcommand>"
}
self.abstract = currentCommand.configuration.abstract
if !currentCommand.configuration.discussion.isEmpty {
if !self.abstract.isEmpty {
self.abstract += "\n"
}
self.abstract += "\n\(currentCommand.configuration.discussion)"
}
self.usage = usage
self.sections = HelpGenerator.generateSections(commandStack: commandStack)
self.discussionSections = []
}