-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlauncher
52 lines (42 loc) · 1.22 KB
/
launcher
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
#!/bin/bash
# Check if the correct number of arguments is provided
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "Usage: $0 [-i|--interactive|-a|--automatic] image [database_path]"
exit 1
fi
# Parse command line arguments
mode=""
image_to_compare="$2"
database_path="$3"
while [[ $# -gt 0 ]]; do
case "$1" in
-i | --interactive)
mode="--interactive"
shift
;;
-a | --automatic)
mode="--automatic"
shift
;;
*)
shift
;;
esac
done
# Initialize database_path to "img/" if not provided
if [ -z "$database_path" ]; then
database_path="img/"
fi
# Add a trailing "/" to database_path if it doesn't have one
if [ ! -z "$database_path" ] && [ "${database_path: -1}" != "/" ]; then
database_path="$database_path/"
fi
# Check if the specified database path is a directory
if [ ! -d "$database_path" ]; then
echo "The specified database path is not a directory." >&2
exit 2
fi
# Modify the $PATH variable to include the img-dist directory
export PATH="$PATH:$(pwd)/img-dist/"
# Run img-search with the provided mode, image, and database path
./img-search "$mode" "$image_to_compare" "$database_path"