feat: Adds command documentation about piping to other commands.
This commit is contained in:
@@ -26,14 +26,33 @@ extension Array where Element == Example {
|
|||||||
))
|
))
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addingPipeToOtherCommand(command: String) -> Self {
|
||||||
|
var output = self
|
||||||
|
output.append((
|
||||||
|
label: "Piping output to other command.",
|
||||||
|
example: "\(command) --quiet | xargs open"
|
||||||
|
))
|
||||||
|
return output
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ExampleSection where Header == String, Label == String {
|
extension ExampleSection where Header == String, Label == String {
|
||||||
static func `default`(examples: [Example], usesPassingExtraOptions: Bool = true) -> some TextNode {
|
static func `default`(
|
||||||
|
examples: [Example],
|
||||||
|
usesPassingExtraOptions: Bool = true,
|
||||||
|
usesPipeToOtherCommand: Bool = true
|
||||||
|
) -> some TextNode {
|
||||||
var examples = examples
|
var examples = examples
|
||||||
if usesPassingExtraOptions, let first = examples.first {
|
|
||||||
|
if let first = examples.first {
|
||||||
|
if usesPassingExtraOptions {
|
||||||
examples = examples.addingPassingOptions(command: first.example)
|
examples = examples.addingPassingOptions(command: first.example)
|
||||||
}
|
}
|
||||||
|
if usesPipeToOtherCommand {
|
||||||
|
examples = examples.addingPipeToOtherCommand(command: first.example)
|
||||||
|
}
|
||||||
|
}
|
||||||
return Self(examples: examples) {
|
return Self(examples: examples) {
|
||||||
"EXAMPLES:"
|
"EXAMPLES:"
|
||||||
} label: {
|
} label: {
|
||||||
|
|||||||
Reference in New Issue
Block a user