summaryrefslogtreecommitdiff
path: root/actions.sh
blob: 9eb4a3711f94734278abfff9fcb9ec613be98802 (plain)
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
#!/usr/bin/env sh

set -euC

help_text=

help_text="$help_text  run_tests\t[arg]\tpasses arg to the 'prove' tool\n"
run_tests () {
    eval "prove -l ${1-} t/"
}

help_text="$help_text  start_dev\t[]\tstarts a hot reloading dev server\n"
start_dev () {
    morbo script/jwebmail
}

help_text="$help_text  logrotate\t[mode]\tarives the current log file\n"
logrotate () {
    mode=${1:-development}
    mv -i "log/$mode.log" "log/${mode}_$(date --iso-8601=minutes).log"
}

help_text="$help_text  linelength\t[files]\tchecks documentation files for overly long lines\n"
linelength () {
    files=${1:-'README.md CHANGES.md LICENSE'}
    for file in $files
    do
        fold -s -w 85 "$file" | diff "$file" -
    done
}

help_text="$help_text  follow\t[mode]\tfollows the current log file\n"
follow () {
    mode=${1:-development}
    tail -f "log/$mode.log"
}

help_text="$help_text  check_manifest\t[]\tchecks if files in the MANIFEST actually exist\n"
check_manifest () {
    perl -nE 'chomp; say unless -e' MANIFEST
}

help_text="$help_text  list_deps\t[]\tlists all non core dependencies\n"
list_deps () {
    core="$(corelist -v v5.34.1 | awk '{ print $1 }')"
    deps="$(perl -wE 'use lib "lib"; use Module::Load::Conditional "requires"; @res = requires "JWebmail"; $" = "\n"; say $res[0] ? "@res" : ""')"

    for dep in $deps
    do
        if echo "$core" | grep -qxF "$dep"
        then :
        else echo "$dep"
        fi
    done
}

help () {
    echo "The following actions are available:"
    echo
    printf "$help_text" | expand -t 19,29
    echo
}

if [ $# -gt 0 ]
then cmd=$1; shift
else cmd=help
fi
if [ "$(command -v "$cmd")" = "$cmd" ]
then eval "$cmd" "$@"
else echo "unkown commad '$cmd'"; exit 1
fi