-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·110 lines (95 loc) · 2.32 KB
/
Copy pathrun
File metadata and controls
executable file
·110 lines (95 loc) · 2.32 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
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
#!/usr/bin/env bash
#
# usage: ./run command [argument ...]
#
# Commands for halos-docs-tools development.
#
set -o nounset
set -o pipefail
set -o errexit
# Change the current directory to the project root.
PROJECT_ROOT=${0%/*}
if [[ $0 != $PROJECT_ROOT && $PROJECT_ROOT != "" ]]; then
cd "$PROJECT_ROOT"
fi
readonly PROJECT_ROOT=$(pwd)
################################################################################
# Development Commands
function deps {
#@ Install dependencies into the project virtualenv
#@ Category: Development
uv sync
}
function test {
#@ Run the test suite
#@ Category: Development
uv run pytest "$@"
}
function lint {
#@ Check the sources with ruff
#@ Category: Quality
uv run ruff check src/ tests/
}
function format {
#@ Reformat the sources with ruff
#@ Category: Quality
uv run ruff format src/ tests/
}
function check {
#@ Run lint and tests, as CI does
#@ Category: Quality
lint
test
}
function install-hooks {
#@ Install the lefthook pre-commit hooks
#@ Category: Development
lefthook install
}
################################################################################
# Core
function help {
#@ Show this help message
#@ Category: Core
echo "HaLOS Docs Tools - Development Commands"
echo "======================================="
echo ""
echo "Available commands:"
echo ""
# Extract function definitions and their help comments
awk '/^function / {
fname = $2
sub(/[({].*/, "", fname)
getline
if ($0 ~ /#@/) {
desc = $0
sub(/.*#@ /, "", desc)
sub(/ *$/, "", desc)
getline
if ($0 ~ /#@ Category:/) {
cat = $0
sub(/.*Category: /, "", cat)
sub(/ *$/, "", cat)
if (!seen[cat]++) categories[++cat_count] = cat
commands[cat, ++cmd_count[cat]] = fname
descriptions[cat, cmd_count[cat]] = desc
}
}
}
END {
for (i = 1; i <= cat_count; i++) {
cat = categories[i]
print "\n" cat ":"
for (j = 1; j <= cmd_count[cat]; j++) {
printf " %-25s %s\n", commands[cat, j], descriptions[cat, j]
}
}
}' "$0"
echo ""
echo "Usage: ./run <command> [arguments...]"
echo ""
}
################################################################################
# Commands end.
TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}"