+#!/bin/sh
+# $TheSupernovaDuo$
+# (o)rin - my personal e-mail assistant in posix shell
+
+# Source code:
+# - https://gitler.moe/novaburst/orin
+# - https://git.chaotic.ninja/yakumo.izuru/orin
+
+# Check for mail in the server
+# Arguments: <account>
+fn_check() {
+ fdm -a "$@" poll 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "ごめんなさい、できませんでした..."
+ exit 1
+ fi
+}
+
+# Clean-up the Maildir directory
+# Arguments: <account>
+fn_clean() {
+ find "$@"/cur -type f -print -delete
+}
+# Fetch e-mails from remote server
+# Arguments: <account>
+fn_fetch() {
+ echo "はい、すぐに!"
+ fdm -a "$@" fetch 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "ごめんなさい、できませんでした..."
+ exit 1
+ fi
+}
+# List messages on a Maildir
+# Arguments: <account>
+fn_list() {
+ minc -q "$HOME/Mail/$@/INBOX"
+ mlist -s "$HOME/Mail/$@/INBOX" | msort -dr | mthread -r | mseq -S | mscan
+}
+# Print an usage note
+# Triggered if the assistant is called without any arguments.
+fn_usage() {
+ printf "usage: %s [ check | clean | fetch | list ] <account/message> \n" "$(basename $0)"
+}
+case $1 in
+check)
+ fn_check "$2"
+ ;;
+clean)
+ fn_clean "$2"
+ ;;
+fetch)
+ fn_fetch "$2"
+ ;;
+list)
+ fn_list "$2"
+ ;;
+*)
+ fn_usage
+ ;;
+esac