-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate-tools-list.sh
executable file
·78 lines (58 loc) · 2.04 KB
/
update-tools-list.sh
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
#!/bin/sh
# Create a list of available tools using tools' README files,
# and add to README.md
STABLE_DIR="stable"
DEV_DIR="development"
UNMAINTAINED_DIR="unmaintained"
FILENAME="README.md"
write_tools_on_dir() {
find "$1" -mindepth 1 -maxdepth 1 -type d 2>/dev/null |while read -r TOOL_PATH; do
TOOL_NAME="$(echo "${TOOL_PATH}" | sed 's:.*/::')"
# Add to list if a Dockerfile exists
if [ -f "$TOOL_PATH"/Dockerfile ]
then
if [ -f "$TOOL_PATH"/README.md ]
then
DESCRIPTION="$(head -n 1 "$TOOL_PATH"/README.md | sed 's/#//g; s/\"//g';)"
INPUTS="$(sed -e '1,/Input/d;/Output/,$d;1,/```/d;/```/,$d;' "$TOOL_PATH"/README.md \
|tr '\n' ' ')"
else
DESCRIPTION=""
INPUTS=""
fi
echo "| [$TOOL_NAME](https://gitlab.com/CinCan/tools/-/tree/master/$TOOL_PATH) | $DESCRIPTION | $INPUTS | Linux |" >> "$2"
fi
done
}
touch temp-stable.md temp-dev.md temp-unmaintained.md temp-linux.md
# Stable tools at first
write_tools_on_dir "$STABLE_DIR" "temp-stable.md"
cat >> temp-linux.md << EOL
### Linux tools
### Stable
| Tool name | Description | Input | Platform |
|-----------|-------------|---------------------|----------|
EOL
# Sort list by Input column
sort -t "|" -k2,2 temp-stable.md >> temp-linux.md
# Development tools
write_tools_on_dir "$DEV_DIR" "temp-dev.md"
cat >> temp-linux.md << EOL
### In Development
| Tool name | Description | Input | Platform |
|-----------|-------------|---------------------|----------|
EOL
sort -t "|" -k2,2 temp-dev.md >> temp-linux.md
# Unmaintained tools
write_tools_on_dir "$UNMAINTAINED_DIR" "temp-unmaintained.md"
cat >> temp-linux.md << EOL
### Not maintained anymore
It is very possible that some of these are not working.
| Tool name | Description | Input | Platform |
|-----------|-------------|---------------------|----------|
EOL
sort -t "|" -k2,2 temp-unmaintained.md >> temp-linux.md
# Cut off the old list of tools
sed -i '/## Description*/q' "$FILENAME"
cat temp-linux.md >> "$FILENAME"
rm temp-linux.md temp-stable.md temp-dev.md temp-unmaintained.md