Skip to content

Commit

Permalink
Make ArgCommand async
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Jul 2, 2024
1 parent 86a3af7 commit 6f8fecb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/D2Commands/ArgCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ public protocol ArgCommand: StringCommand {
/// Fetches the _pattern instantation_ of the required argument format.
var argPattern: Args { get }

func invoke(with input: Args, output: any CommandOutput, context: CommandContext)
func invoke(with input: Args, output: any CommandOutput, context: CommandContext) async
}

extension ArgCommand {
public var inputValueType: RichValueType { .text }

public func invoke(with input: String, output: any CommandOutput, context: CommandContext) {
public func invoke(with input: String, output: any CommandOutput, context: CommandContext) async {
let words = input.split(separator: " ").map { String($0) }
if let args = Args.parse(from: TokenIterator(words)) {
invoke(with: args, output: output, context: context)
await invoke(with: args, output: output, context: context)
} else {
output.append(errorText: "Syntax: `\(argPattern)`")
}
Expand Down

0 comments on commit 6f8fecb

Please sign in to comment.