summaryrefslogtreecommitdiffstats
path: root/lass/5pkgs/review-mail-queue/default.nix
blob: c8c66706cf32fbf79c4912d74a27bf345a5397cb (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
{ pkgs }: let

  review = pkgs.writers.writeBash "review-mail" ''
    mail="$1"
    ${pkgs.exim}/bin/exim -Mvc "$mail" | grep -E 'Subject:|To:'
    ${pkgs.exim}/bin/exim -Mvl "$mail"
    while :; do
    read -p 'delete?' key
      case "$key" in
        v*)
          ${pkgs.exim}/bin/exim -Mvc "$mail"
        ;;
        d*)
          ${pkgs.exim}/bin/exim -Mrm "$mail"
          break
        ;;
        r*)
          ${pkgs.exim}/bin/exim -Mt "$mail"
          break
        ;;
        n*)
          break
        ;;
      esac
    done
    echo '-------------------'
    echo '-------------------'
    echo '-------------------'
    echo '-------------------'
    echo '-------------------'
  '';

in pkgs.writers.writeBashBin "review-mail" ''
  for mail in $(${pkgs.exim}/bin/exim -bp \
  | ${pkgs.gnugrep}/bin/grep frozen \
  | ${pkgs.gawk}/bin/awk '{print $3}'); do
    ${review} "$mail"
  done
''