-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisort.sh
More file actions
executable file
·73 lines (60 loc) · 1.24 KB
/
isort.sh
File metadata and controls
executable file
·73 lines (60 loc) · 1.24 KB
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
#!/usr/bin/env bash
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit; pwd)
USAGE="
Usage: ${BASH_SOURCE[0]} [options]
Available options are:
-h, --help Print this message.
-f, --fix Edit files in place.
-i, --in-place Same '--fix' flag.
-- Stop handling options.
"
FIX_FLAG=0
function print_error
{
# shellcheck disable=SC2145
echo -e "\033[31m$@\033[0m" 1>&2
}
function print_message
{
# shellcheck disable=SC2145
echo -e "\033[32m$@\033[0m"
}
function on_interrupt_trap
{
print_error "An interrupt signal was detected."
exit 1
}
function print_usage
{
echo "$USAGE"
}
trap on_interrupt_trap INT
while [[ -n $1 ]]; do
case $1 in
-h|--help)
print_usage
exit 0
;;
-f|--fix|-i|--in-place)
FIX_FLAG=1
shift
;;
--)
shift
break
;;
*)
print_error "Unknown option: $1"
exit 1
;;
esac
done
ARGS=("--settings-path=$ROOT_DIR/isort.cfg")
if [[ $FIX_FLAG -eq 0 ]]; then
ARGS+=("--check" "--diff" "--color")
fi
print_message "isort ${ARGS[*]}"
"$ROOT_DIR/python" -m isort "${ARGS[@]}" \
"$ROOT_DIR/__PACKAGE_LOWER__/" \
"$ROOT_DIR/tester/" \
"$ROOT_DIR/setup.py"