/
84-sap-btp.sh
57 lines (41 loc) · 1.07 KB
/
84-sap-btp.sh
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
#!/usr/bin/env bash
# For SAP's btp CLI
# Where to store the config
export BTP_CLIENTCONFIG=$HOME/.config/btp/config.json
# Autocompletion - see
# https://help.sap.com/products/BTP/65de2977205c403bbc107264b8eccf4b/46355fab22814944bedf449a6c953369.html
btpautocomplete="$HOME/.config/btp/autocomplete/scripts/sapbtpcli-autocomplete.plugin.sh"
# shellcheck disable=1090
test -f "$btpautocomplete" \
&& source "$btpautocomplete" \
&& bind 'set show-all-if-ambiguous on'
btpwrapper() {
local OUTFILE="/tmp/btpcli"
if "$HOME/bin/btp" "$@" > "$OUTFILE.out" 2> "$OUTFILE.err"; then
cat "$OUTFILE.out"
else
rc=$?
cat "$OUTFILE.err"
return $rc
fi
}
btp() {
if [[ $1 =~ ^(get|list)$ ]]; then
btpwrapper "$@" | trunc
else
"$HOME/bin/btp" "$@"
fi
}
btpgo() {
clear \
&& btplogin "${1:?Specify account}" \
&& btp get accounts/global-account --show-hierarchy \
&& btpctx > "$HOME/.status"
}
bgu() {
btpguid "$@"
if [[ $# -gt 1 ]]; then
btpctx > "$HOME/.status"
fi
}
alias btphier='btp get accounts/global-account --show-hierarchy'