gosmartkeyboard/tools/Input.md

38 lines
710 B
Markdown
Raw Normal View History

2023-01-23 04:59:12 +00:00
# Simple Input
This tool reads lines from stdin and sends them to the server.
Newline characters are only sent when a blank line is entered.
``` go
--- /tools/input/input.go
package main
import (
"io/ioutil"
"bufio"
"os"
)
func main(){
var input string
2023-03-03 03:20:34 +00:00
@{get client input file from environment}
2023-01-23 04:59:12 +00:00
if ! clientFifoInputFileExists {
os.Exit(1)
}
for {
reader := bufio.NewReader(os.Stdin)
input, _ = reader.ReadString('\n')
if len(input) > 0 {
ioutil.WriteFile(clientFifoInputFile, []byte(input), 0644)
} else {
ioutil.WriteFile(clientFifoInputFile, []byte("\n"), 0644)
}
input = ""
}
}
---