Skip to content

Commit 96dffec

Browse files
authored
Merge pull request #20 from OpenFuturePlatform/brew-prepare
Brew prepare #5
2 parents f875919 + b9004e8 commit 96dffec

5 files changed

Lines changed: 125 additions & 20 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ There are two modes to create a snapshot.
1010
Works with Infura free plan.
1111

1212
## Running the application
13-
Run from the command line `snapshot` script.
13+
Run from the command line `token-snapshot` script.
1414

1515
Input arguments:
1616
* `-n, --node-address` Server url of node connected to [_required_]

snapshot

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/main/kotlin/io/openfuture/snapshot/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import io.openfuture.snapshot.snapshot.ArchivedNodeBasedSnapshotCreator
1212
import io.openfuture.snapshot.snapshot.EventBasedSnapshotCreator
1313
import io.openfuture.snapshot.snapshot.SnapshotCreator
1414

15-
class CommandLineSnapshotRunner : CliktCommand(name = "snapshot") {
15+
class CommandLineSnapshotRunner : CliktCommand(name = "token-snapshot") {
1616

1717
private val nodeAddress: String by option("-n", "--node-address", help = "Server url of node to connect")
1818
.required()

token-snapshot

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -z "$TOKEN_SNAPSHOT_PATH" ]; then
4+
export TOKEN_SNAPSHOT_PATH=$PWD
5+
fi
6+
7+
# BUILD CHECK
8+
BUILD_JAR_PATH=$TOKEN_SNAPSHOT_PATH/build/libs/snapshot-0.0.1-SNAPSHOT.jar
9+
if [ ! -f "$BUILD_JAR_PATH" ]; then
10+
"$TOKEN_SNAPSHOT_PATH"/gradlew build
11+
fi
12+
13+
# RUN
14+
java -jar "$BUILD_JAR_PATH" "$@"

token-snapshot-completion.sh

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env bash
2+
# Command completion for token-snapshot
3+
# Generated by Clikt
4+
5+
__skip_opt_eq() {
6+
# this takes advantage of the fact that bash functions can write to local
7+
# variables in their callers
8+
(( i = i + 1 ))
9+
if [[ "${COMP_WORDS[$i]}" == '=' ]]; then
10+
(( i = i + 1 ))
11+
fi
12+
}
13+
14+
_token_snapshot() {
15+
local i=1
16+
local in_param=''
17+
local fixed_arg_names=()
18+
local vararg_name=''
19+
local can_parse_options=1
20+
21+
while [[ ${i} -lt $COMP_CWORD ]]; do
22+
if [[ ${can_parse_options} -eq 1 ]]; then
23+
case "${COMP_WORDS[$i]}" in
24+
--)
25+
can_parse_options=0
26+
(( i = i + 1 ));
27+
continue
28+
;;
29+
-n|--node-address)
30+
__skip_opt_eq
31+
(( i = i + 1 ))
32+
[[ ${i} -gt COMP_CWORD ]] && in_param='--node-address' || in_param=''
33+
continue
34+
;;
35+
-c|--contract)
36+
__skip_opt_eq
37+
(( i = i + 1 ))
38+
[[ ${i} -gt COMP_CWORD ]] && in_param='--contract' || in_param=''
39+
continue
40+
;;
41+
-f|--from)
42+
__skip_opt_eq
43+
(( i = i + 1 ))
44+
[[ ${i} -gt COMP_CWORD ]] && in_param='--from' || in_param=''
45+
continue
46+
;;
47+
-t|--to)
48+
__skip_opt_eq
49+
(( i = i + 1 ))
50+
[[ ${i} -gt COMP_CWORD ]] && in_param='--to' || in_param=''
51+
continue
52+
;;
53+
-o|--output)
54+
__skip_opt_eq
55+
(( i = i + 1 ))
56+
[[ ${i} -gt COMP_CWORD ]] && in_param='--output' || in_param=''
57+
continue
58+
;;
59+
-m|--mode)
60+
__skip_opt_eq
61+
(( i = i + 1 ))
62+
[[ ${i} -gt COMP_CWORD ]] && in_param='--mode' || in_param=''
63+
continue
64+
;;
65+
-h|--help)
66+
__skip_opt_eq
67+
in_param=''
68+
continue
69+
;;
70+
esac
71+
fi
72+
case "${COMP_WORDS[$i]}" in
73+
*)
74+
(( i = i + 1 ))
75+
# drop the head of the array
76+
fixed_arg_names=("${fixed_arg_names[@]:1}")
77+
;;
78+
esac
79+
done
80+
local word="${COMP_WORDS[$COMP_CWORD]}"
81+
if [[ "${word}" =~ ^[-] ]]; then
82+
COMPREPLY=($(compgen -W '-n --node-address -c --contract -f --from -t --to -o --output -m --mode -h --help' -- "${word}"))
83+
return
84+
fi
85+
86+
# We're either at an option's value, or the first remaining fixed size
87+
# arg, or the vararg if there are no fixed args left
88+
[[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]}
89+
[[ -z "${in_param}" ]] && in_param=${vararg_name}
90+
91+
case "${in_param}" in
92+
--node-address)
93+
;;
94+
--contract)
95+
;;
96+
--from)
97+
;;
98+
--to)
99+
;;
100+
--output)
101+
;;
102+
--mode)
103+
;;
104+
--help)
105+
;;
106+
esac
107+
}
108+
109+
complete -F _token_snapshot token-snapshot ./token-snapshot

0 commit comments

Comments
 (0)