forked from Worldie-com/pen.el
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapostrophe
More file actions
executable file
·129 lines (105 loc) · 2.71 KB
/
apostrophe
File metadata and controls
executable file
·129 lines (105 loc) · 2.71 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
export TTY
sn="$(basename "$0")"
# Apostrophe
# Version 1.0, bash
# Apostrophe is a figure of speech in which a speaker directly addresses someone
# (or something) that is not present or cannot respond in reality. ... An
# apostrophe is often introduced by the exclamation "O," as when Juliet cries
# out: "O Romeo, Romeo, Wherefore art thou Romeo?"
FRAMETYPE=tty
apostrophe-logo 1>&2
while [ $# -gt 0 ]; do opt="$1"; case "$opt" in
"") { shift; }; ;;
-nv) {
USE_NVC=y
shift
}
;;
-human|-talk-to-human) {
PEN_ENGINE=Human
shift
}
;;
-engine) {
PEN_ENGINE="$2"
shift
shift
}
;;
-temp|-temperature) {
export PEN_TEMPERATURE="$2"
shift
shift
}
;;
-tty|-nw|-t) {
export PEN_USE_GUI=n
FRAMETYPE=tty
shift
}
;;
-context) {
context="$2"
shift
shift
}
;;
-win) {
context="$(pen-tm cap-pane -nohist)"
shift
}
;;
-gui) {
export PEN_USE_GUI=y
FRAMETYPE=gui
shift
}
;;
*) break;
esac; done
export USE_NVC
export PEN_UPDATE
export PEN_ENGINE
PEN_ENGINE_ELISP="$PEN_ENGINE"
if test "$PEN_ENGINE" = nil; then
PEN_ENGINE_ELISP=nil
elif test -n "$PEN_ENGINE"; then
PEN_ENGINE_ELISP="\"$PEN_ENGINE\""
else
PEN_ENGINE_ELISP=nil
fi
stdin_exists() {
! [ -t 0 ] && ! test "$(readlink /proc/$$/fd/0)" = /dev/null
}
# test -n "$person" || {
# echo "Person name required as parameter." 12
# exit 1
# }
if test "$#" -eq 0; then
person="$(pen-readln "Chatbot name")"
else
person="$@"
fi
# PEN_USE_GUI is unset by design apparently
if test -z "$person"; then
{
echo "$sn, for the moment, needs requires you to name a person in its arguments"
echo "For example:"
echo "$ $sn \"Amber Heard\""
} 1>&2
exit 1
fi
if stdin_exists; then
context="$(cat)"
fi
if test -n "$context"; then
# Rather than specifying directly to the prompt function,
# this value is taken up and remembered for future prompting within the apostrophe
pen -nn -frametype "$FRAMETYPE" --pool -ic "(pen-engine $PEN_ENGINE_ELISP (progn (upd (apostrophe-start-chatbot-from-selection $(cmd-nice-posix "$context")))(delete-other-windows)))"
elif test -n "$person"; then
exec <&1
pen -nn -frametype "$FRAMETYPE" --pool -ic "(pen-engine $PEN_ENGINE_ELISP (progn (upd (apostrophe-start-chatbot-from-name $(cmd-nice-posix "$person") t))(delete-other-windows)))"
else
pen -nn -frametype "$FRAMETYPE" --pool -ic "(pen-engine $PEN_ENGINE_ELISP (progn (upd (call-interactively 'apostrophe-start-chatbot-from-name))(delete-other-windows)))"
fi