Files
swift-hpa/Sources/hpa/Internal/CommandConfigurationExtensions.swift

50 lines
1.0 KiB
Swift

import ArgumentParser
import CliDoc
import Rainbow
extension CommandConfiguration {
static func playbook(
commandName: String,
abstract: String,
parentCommand: String? = nil,
examples: Example...
) -> Self {
.init(
commandName: commandName,
abstract: Abstract { abstract.blue },
usage: Usage.default(commandName: commandName, parentCommand: parentCommand),
discussion: Discussion.playbook(examples: examples)
)
}
}
func createAbstract(_ string: String) -> String {
"\(string.blue)"
}
extension Usage where Content == AnyTextNode {
static func `default`(commandName: String, parentCommand: String?) -> Self {
.init {
HStack {
HStack {
"\(Constants.appName)"
if let parentCommand {
parentCommand
}
commandName
}
.color(.blue).bold()
"[OPTIONS]".color(.green)
"[ARGUMENTS]".color(.cyan)
"--"
"[EXTRA-OPTIONS]".color(.magenta)
}
.eraseToAnyTextNode()
}
}
}