Skip to content

Commit

Permalink
fix: display help when no commands supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
socsieng committed Dec 31, 2020
1 parent 409e0fb commit c3175ba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/SendKeysLib/SendKeysCli.swift
Expand Up @@ -51,14 +51,21 @@ public struct SendKeysCli: ParsableCommand {

if !(commandString ?? "").isEmpty {
commandProcessor.process(commandString!)
} else {
} else if !isTty() {
var data: Data

repeat {
data = FileHandle.standardInput.availableData

commandString = String(data: data, encoding: .utf8)
commandProcessor.process(commandString!)
} while data.count > 0
} else {
print(SendKeysCli.helpMessage())
}
}

private func isTty() -> Bool {
return isatty(FileHandle.standardInput.fileDescriptor) == 1
}
}

0 comments on commit c3175ba

Please sign in to comment.