func validate(args []string) error {
	for _, d := range validDest {
		if args[1] == d {
			break
		}
	}
	if args[1] == "at" && !strings.Contains(args[2], ":") {
		return errors.New("error: invalid format for 'at'")
	}
	if args[1] == "in" {
		_, err := time.ParseDuration(args[2])
		if err != nil {
			return err
		}
		if !strings.Contains(args[2], "m") && !strings.Contains(args[2], "h") {
			return errors.New("error: unsupported duration. Only 'm' or 'h' currently supported")
		}
	}
	if args[1] == "on" && !strings.Contains(args[2], "/") {
		return errors.New("error: invalid format for 'on'")
	}
	return nil
}
validate checks what is given by the user from
the terminal and makes sure it's able to be
successfully processed.
package main
import (
	"bytes"
	"errors"
	"flag"
	"fmt"
	"io"
	"net"
	"os"
	"strconv"
	"strings"
	"syscall"
	"time"
	"github.com/martinlindhe/notify"
	"github.com/robfig/cron/v3"
	"go.uber.org/zap"
)
var (
	name    string
	version string
	gitSHA  string
)
const usage = `version: %s
Usage: %[2]s [-v] [-h] [-s]
Options:
    -s        run the server
    -h        help
    -v        show version and exit
Examples:
    %[2]s at 09:16 "call the handyman"
    %[2]s in 5m "login to the meeting"
    %[2]s on 08/17 "buy a birthday card"
`
const (
	remindmeSock = "/tmp/remindme.sock"
	remindmePid = "/tmp/remindme.pid"
	maxArgs = 4
)
var validDest = []string{"at", "in", "on"}
const (
	timerNotification = iota
	cronNotification
)
type notification struct {
	notificationType int
	id               int
	spec             string
	text             string
	c                *cron.Cron
	dur              time.Duration
}
func (n notification) Run() {
	notify.Alert("remindme", "", n.text, "")
	n.c.Remove(cron.EntryID(n.id))
}
func parse(conn net.Conn, c *cron.Cron) (*notification, error) {
	b := bytes.NewBuffer(nil)
	io.Copy(b, conn)
	parts := strings.Split(b.String(), "|")
	n := notification{
		text: parts[2],
		c:    c,
	}
	switch parts[0] {
	case "at":
		at := strings.Split(parts[1], ":")
		hour, minute := at[0], at[1]
		n.notificationType = cronNotification
		n.spec = minute + " " + hour + " * * *"
	case "in":
		dur, err := time.ParseDuration(parts[1])
		if err != nil {
			return nil, err
		}
		n.notificationType = timerNotification
		n.dur = dur
	case "on":
		on := strings.Split(parts[1], "/")
		month, day := on[0], on[1]
		n.notificationType = cronNotification
		n.spec = "* * " + day + " " + month + " * *"
	default:
		return nil, errors.New("invalid descriptor")
	}
	return &n, nil
}