forked from XargonWan/Synthetic_Heart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynth
More file actions
executable file
·37 lines (31 loc) · 835 Bytes
/
synth
File metadata and controls
executable file
·37 lines (31 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# CLI tool to send messages to synth
show_help() {
echo "Usage: synth [-h|--help] [-e|--exec <cmd>] [message]"
echo " -h, --help Show this help"
echo " -e, --exec <cmd> Execute command as terminal"
echo " message Send plain message to synth"
}
SERVER_PORT=5555
SERVER_HOST=127.0.0.1
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
show_help
exit 0
fi
if [[ "$1" == "-e" || "$1" == "--exec" ]]; then
shift
CMD="$*"
if [[ -z "$CMD" ]]; then
echo "No command to execute."
exit 1
fi
echo "{\"type\": \"cli_exec\", \"command\": \"$CMD\"}" | nc $SERVER_HOST $SERVER_PORT
exit 0
fi
if [[ -n "$*" ]]; then
MSG="$*"
echo "{\"type\": \"message_cli\", \"text\": \"$MSG\"}" | nc $SERVER_HOST $SERVER_PORT
exit 0
fi
show_help
exit 1