-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrcargo
executable file
·172 lines (137 loc) · 3.37 KB
/
rcargo
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/env bash
set -e
SELF="$0"
SCRIPT=$(realpath "$SELF")
ROOT_DIR=$(dirname "$SCRIPT")
RCARGO_DIR=".rcargo"
RCARGO_CONFIG_LOCAL="$RCARGO_DIR/config"
ACTIVE_BRANCHES_FILE="$RCARGO_DIR/active_branches.txt"
. $ROOT_DIR/src/build
. $ROOT_DIR/src/check
. $ROOT_DIR/src/clean
. $ROOT_DIR/src/common
. $ROOT_DIR/src/run
. $ROOT_DIR/src/session
. $ROOT_DIR/src/sync
. $ROOT_DIR/src/test
rcargo_usage() {
cat << EOF
Usage:
rcargo <FLAG>
rcargo <COMMAND> <SUBCOMMAND> [CARGO FLAGS]
rcargo is a remote build tool for faster Rust development, using the Cargo
package manager.
Flags:
-h, --help show help message and exit
Commands:
help show help message and exit
build, b Compile the current package
check, c Analyze the current package and report errors, but don't build object files
clean Remove artifacts that cargo has generated in the past
run, r Run a binary or example of the local package
session Manage multiple development sessions i.e. git branches
sync Sync local repository to remote, or vice versa
test, t Execute all unit and integration tests and build examples of a local package
Try rcargo <COMMAND> -h (or --help) to learn more about each command.
Default config is located at $ROOT_DIR/$RCARGO_CONFIG_LOCAL
EOF
}
COMMAND="$1"
if [ "$#" -ne "0" ]
then
shift
fi
MAYBE_SUBCOMMAND="$1"
case "$COMMAND" in
"" | -h | --help | help)
rcargo_usage
exit; ;;
build | b)
case "$MAYBE_SUBCOMMAND" in
-h | --help | help)
build_usage
exit; ;;
*)
header "Building package"
build_cargo "$@"; ;;
esac;;
check | c)
case "$MAYBE_SUBCOMMAND" in
-h | --help | help)
check_usage
exit; ;;
*)
header "Checking package"
check_cargo "$@"; ;;
esac;;
clean)
case "$MAYBE_SUBCOMMAND" in
"" | -h | --help | help)
clean_usage
exit; ;;
all)
shift
clean_cargo_all "$@"; ;;
macro-cache)
shift
clean_cargo_macro_cache "$@"; ;;
*)
header "Unknown option: '$MAYBE_SUBCOMMAND'"
format_usage
exit 1; ;;
esac;;
run | r)
case "$MAYBE_SUBCOMMAND" in
-h | --help | help)
run_usage
exit; ;;
*)
header "Running package"
run_cargo "$@"; ;;
esac;;
session)
case "$MAYBE_SUBCOMMAND" in
"" | -h | --help | help)
session_usage
exit; ;;
show)
shift
session_show "$@"; ;;
remove)
shift
session_remove "$@"; ;;
*)
header "Unknown option: '$MAYBE_SUBCOMMAND'"
format_usage
exit 1; ;;
esac;;
sync)
case "$MAYBE_SUBCOMMAND" in
"" | -h | --help | help)
sync_usage
exit; ;;
local-to-remote)
shift
sync_local_to_remote "$@"; ;;
remote-to-local)
shift
sync_remote_to_local "$@"; ;;
*)
header "Unknown option: '$MAYBE_SUBCOMMAND'"
format_usage
exit 1; ;;
esac;;
test | t)
case "$MAYBE_SUBCOMMAND" in
-h | --help | help)
test_usage
exit; ;;
*)
header "Testing package"
test_cargo "$@"; ;;
esac;;
*)
header "Unknown option: '$COMMAND'"
rcargo_usage
exit 1; ;;
esac