blob: 95464a80d2493ddadf36e4f6802049dbb77fbd39 (
plain) (
blame)
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
|
#!/bin/bash
cd "$(dirname "$0")" || exit 1
# Collect all available tool names
tools=()
if [ -d "rola-devtools/scripts" ]; then
for file in rola-devtools/scripts/*.sh; do
if [ -f "$file" ]; then
tools+=("$(basename "$file" .sh)")
fi
done
for file in rola-devtools/scripts/*.py; do
if [ -f "$file" ]; then
tools+=("$(basename "$file" .py)")
fi
done
fi
if [ -d "rola-devtools/src/bin" ]; then
for file in rola-devtools/src/bin/*.rs; do
if [ -f "$file" ]; then
tools+=("$(basename "$file" .rs)")
fi
done
fi
if [ $# -eq 0 ]; then
echo "Available:"
for i in "${!tools[@]}"; do
printf " [%2d] %s\n" $((i + 1)) "${tools[$i]}"
done
exit 1
fi
target_bin="$1"
shift # Remove the first argument (tool name), keep the rest as tool arguments
# Check if input is a number
if [[ "$target_bin" =~ ^[0-9]+$ ]]; then
idx=$((target_bin - 1))
if [ "$idx" -ge 0 ] && [ "$idx" -lt "${#tools[@]}" ]; then
target_bin="${tools[$idx]}"
else
echo "Error: invalid number '$target_bin', valid range is 1-${#tools[@]}"
exit 1
fi
fi
target_script="rola-devtools/scripts/${target_bin}.sh"
target_python="rola-devtools/scripts/${target_bin}.py"
target_file="rola-devtools/src/bin/${target_bin}.rs"
if [ -f "$target_script" ]; then
chmod +x "$target_script"
"$target_script" "$@"
elif [ -f "$target_python" ]; then
python "$target_python" "$@"
elif [ -f "$target_file" ]; then
cargo run --manifest-path rola-devtools/Cargo.toml --bin "$target_bin" --quiet -- "$@"
else
echo "Error: target '$target_bin' does not exist"
exit 1
fi
|