-
Notifications
You must be signed in to change notification settings - Fork 0
/
nicer_norminette_42
executable file
·69 lines (52 loc) · 1.84 KB
/
nicer_norminette_42
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
#!/bin/bash
function show_help() {
echo
echo -e "There is a more readable norminette made by \033[1;94mflboulea\033[0m."
echo
echo -e "The command is '\033[1;97mnicer_norminette\033[0m' :"
echo "Use --help or -h to show this message."
echo "Use --open or -o to open the norm pdf."
echo "Use --real-time or -rt and split your window (ctrl + c to escape)."
echo
}
function show_error() {
echo -e "nicer_norminette: incorrect use of this command. See '\033[1;37mnicer_norminette --help\033[0m'."
}
function pretty_norm() {
PN=$(norminette -R CheckForbiddenSourceHeader | grep -v OK! | sed "/Error\!/ s/./\n&/" | sed "s/$/XXX/" | sed "s/^.*Error\!/\\\033[1;97m&\\\033[0m/g" | sed "s/ Error\!//g" | sed "s/^[^(]*(/(/" | sed "s/, col[^)]*)/)/g")
if [ "$PN" ]
then
echo -e $PN | sed "s/XXX /\n/g" | sed "s/XXX/\n/g"
else
echo "Everything Good !"
fi
}
function real_time() {
PN=$(norminette -R CheckForbiddenSourceHeader | grep -v OK! | sed "/Error\!/ s/./\n&/" | sed "s/$/XXX/" | sed "s/^.*Error\!/\\\033[1;97m&\\\033[0m/g" | sed "s/ Error\!//g" | sed "s/^[^(]*(/(/" | sed "s/, col[^)]*)/)/g")
while [ "$PN" ]
do
PN=$(norminette -R CheckForbiddenSourceHeader | grep -v OK! | sed "/Error\!/ s/./\n&/" | sed "s/$/XXX/" | sed "s/^.*Error\!/\\\033[1;97m&\\\033[0m/g" | sed "s/ Error\!//g" | sed "s/^[^(]*(/(/" | sed "s/, col[^)]*)/)/g")
clear && echo -e $PN | sed "s/XXX /\n/g" | sed "s/XXX/\n/g"
sleep 1
done
echo "Good Job !"
}
##########################
####### MAIN #######
##########################
if [ $# == 0 ]; then
pretty_norm
elif [ $# == 1 ];
then
if [ $1 == "--open" ] || [ $1 == "-o" ]; then
xdg-open "https://cdn.intra.42.fr/pdf/pdf/96987/en.norm.pdf"
elif [ $1 == "--real-time" ] || [ $1 == "-rt" ]; then
real_time
elif [ $1 == "--help" ] || [ $1 == "-h" ]; then
show_help
else
show_error
fi
else
show_error
fi