feat: Adds extension to argument parser's command configuration

This commit is contained in:
2024-12-07 09:20:02 -05:00
parent 1a559e0236
commit 45ab7ca578
13 changed files with 250 additions and 5 deletions

View File

@@ -0,0 +1,36 @@
import ArgumentParser
public extension CommandConfiguration {
/// Generate a new command configuration, using ``TextNode``'s for the abstract,
/// usage, and discussion parameters.
///
///
init<A: TextNode, U: TextNode, D: TextNode>(
commandName: String? = nil,
abstract: Abstract<A>,
usage: Usage<U>,
discussion: Discussion<D>,
version: String = "",
shouldDisplay: Bool = true,
subcommands ungroupedSubcommands: [ParsableCommand.Type] = [],
groupedSubcommands: [CommandGroup] = [],
defaultSubcommand: ParsableCommand.Type? = nil,
helpNames: NameSpecification? = nil,
aliases: [String] = []
) {
self.init(
commandName: commandName,
abstract: abstract.render(),
usage: usage.render(),
discussion: discussion.render(),
version: version,
shouldDisplay: shouldDisplay,
subcommands: ungroupedSubcommands,
groupedSubcommands: groupedSubcommands,
defaultSubcommand: defaultSubcommand,
helpNames: helpNames,
aliases: aliases
)
}
}