Unverified Commit cf1f64af authored by Kevin Lyda's avatar Kevin Lyda
Browse files

Initial go setup.

parent 9ff08110
Loading
Loading
Loading
Loading

accounts/accounts.go

0 → 100644
+12 −0
Original line number Diff line number Diff line
// Package accounts manages accounts.
package accounts

import "errors"

// Verify verifies that an account exists.
func Verify(acc string) error {
	if acc == "" {
		return errors.New("Empty account is invalid")
	}
	return nil
}

go.mod

0 → 100644
+5 −0
Original line number Diff line number Diff line
module git.lyda.ie/kevin/bulletin

go 1.24.2

require github.com/urfave/cli/v3 v3.3.2 // indirect

main.go

0 → 100644
+44 −0
Original line number Diff line number Diff line
// Package main is the main program for bulletin.
// It is based off the 1989 version of bulletin.
package main

import (
	"context"
	"fmt"
	"os"

	"git.lyda.ie/kevin/bulletin/accounts"

	"github.com/urfave/cli/v3"
)

func main() {
	cmd := &cli.Command{
		Name:        "bulletin",
		Usage:       "a bulletin system",
		Description: "An interpretation of the VMS BULLETIN program.",
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:     "user",
				Aliases:  []string{"u"},
				Usage:    "user to run bulletin as",
				Value:    "",
				Required: true,
			},
		},
		Action: func(_ context.Context, cmd *cli.Command) error {
			user := cmd.String("user")
			err := accounts.Verify(user)
			if err != nil {
				return err
			}
			fmt.Println("Running as", user)
			return nil
		},
	}

	err := cmd.Run(context.Background(), os.Args)
	if err != nil {
		fmt.Println(err)
	}
}