summaryrefslogtreecommitdiff
path: root/src/rpc.main.bash
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-08-23 19:03:48 -0400
committerAndrew Cady <d@jerkface.net>2023-08-23 19:03:48 -0400
commit5f8d82c9078b3076d7009bd8aa98e10ea3ac70a3 (patch)
tree965b20e9a0bc9a3cd2a6c45b7c29d8187c7d1ff8 /src/rpc.main.bash
parent4f771eac3b737018c44e630d578683abb868846e (diff)
split up rpc.bash into source-able library
Diffstat (limited to 'src/rpc.main.bash')
-rw-r--r--src/rpc.main.bash56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/rpc.main.bash b/src/rpc.main.bash
new file mode 100644
index 0000000..b859509
--- /dev/null
+++ b/src/rpc.main.bash
@@ -0,0 +1,56 @@
1#!/usr/bin/bash -e
2set -e
3set -o pipefail
4
5case "$0" in
6 [^/]* ) PATH=$(realpath -e "$(dirname "$BASH_SOURCE")"):$PATH ;;
7esac
8
9. rpc.bash
10
11our_main()
12{
13 REMOTE_DEST=localhost
14 main2 "$@"
15 main1 "$@"
16}
17
18main1()
19{
20 remote_run_function fudge "$@"
21}
22
23main2()
24{
25 funcs=$(find_local_only_functions "$@" </dev/null | xargs)
26 [ ! "$funcs" ] || printf 'Local-only functions (main2): %s\n' "$funcs" >&2
27}
28
29find_local_only_functions()
30{
31 intersection <(extract_words < "$BASH_SOURCE") \
32 <(difference <(all_commands) \
33 <(remote_run_function all_commands))
34}
35
36all_commands()
37{
38 : main2
39 compgen -A command | sort -u
40}
41
42gudge()
43{
44 echo "Hello, ${REPLY@Q}."
45 topic=${*@Q}
46 echo "Don't argue with me about ${topic:-punctuation}."
47}
48
49fudge()
50{
51 read -p 'Name? ' && gudge "$@"
52 exit
53}
54
55our_main "$@"
56