-
Notifications
You must be signed in to change notification settings - Fork 4
/
cql
executable file
·72 lines (61 loc) · 1.47 KB
/
cql
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
#!/usr/bin/env bash
# [[file:~/src/github/org-kungfu/org-kungfu.org::cql][cql]]
set -e
get-config() {
git config -f ~/.config/org-kungfu/config.ini "$@"
}
user=$(get-config ok.username)
pass=$(get-config ok.password)
wikiurl=$(get-config ok.wikiurl)
## start code-generator "^\\s *#\\s *"
# generate-getopt q:cql-str e:extra-args
## end code-generator
## start generated code
TEMP=$( getopt -o q:e:h \
--long cql-str:,extra-args:,help \
-n $(basename -- $0) -- "$@")
declare cql_str=
declare extra_args=
eval set -- "$TEMP"
while true; do
case "$1" in
-q|--cql-str)
cql_str=$2
shift 2
;;
-e|--extra-args)
extra_args=$2
shift 2
;;
-h|--help)
set +x
echo -e
echo
echo Options and arguments:
printf %6s '-q, '
printf %-24s '--cql-str=CQL_STR'
echo
printf %6s '-e, '
printf %-24s '--extra-args=EXTRA_ARGS'
echo
exit
shift
;;
--)
shift
break
;;
*)
die "internal error: $(. bt; echo; bt | indent-stdin)"
;;
esac
done
## end generated code
if test -z "${cql_str}"; then
cql_str="$*"
fi
cql_str=$(
urlify "$cql_str"
)
curl -u "${user}:${pass}" "${wikiurl}rest/api/search?cql=$cql_str${extra_args}"
# cql ends here