gosmartkeyboard/tools/Input.md

38 lines
717 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-09 05:08:28 +00:00
@{get client fifo input file from environment}
if ! clientFifoInputFileEnvExists {
2023-01-23 04:59:12 +00:00
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 = ""
}
}
---