initial attempt at building Masonry

This commit is contained in:
2025-02-12 22:14:44 -07:00
commit e34da045bc
12 changed files with 187 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package daemon
type DaemonService interface {
Start()
Stop()
}
type Daemon struct {
services []DaemonService
}
func (d *Daemon) RegisterDaemonServer(service DaemonService) {
d.services = append(d.services, service)
}
func (d *Daemon) Start() {
for _, service := range d.services {
go service.Start()
}
}
func (d *Daemon) Stop() {
for _, service := range d.services {
service.Stop()
}
}

View File

@ -0,0 +1,3 @@
# Daemon
A library that provides a way to register and start multiple long-running services with safe tear-down when they are done.

View File

@ -0,0 +1,5 @@
package main
func main() {
}

38
templates/cli/cli.go Normal file
View File

@ -0,0 +1,38 @@
package main
import (
"fmt"
"github.com/urfave/cli/v2"
"os"
"time"
)
func main() {
commands := []*cli.Command{
exampleCmd(),
// call your command functions from the commands.go file
}
app := &cli.App{
Name: "ExampleApp",
Usage: "An example CLI tool",
Version: "v1.0.0",
Description: "This is an example CLI tool",
Commands: commands,
Flags: nil,
Authors: []*cli.Author{
{
Name: "Mason Payne", // Update this to your name
Email: "mason@masonitestudios.com", // Update this to your email
},
},
Copyright: fmt.Sprintf("%d Example Corp", time.Now().Year()),
UseShortOptionHandling: true,
}
err := app.Run(os.Args)
if err != nil {
fmt.Println(fmt.Errorf("error running app | %w", err))
return
}
}

20
templates/cli/commands.go Normal file
View File

@ -0,0 +1,20 @@
package main
import (
"fmt"
"github.com/urfave/cli/v2"
)
func exampleCmd() *cli.Command {
return &cli.Command{
Name: "example",
Aliases: []string{"e"},
Usage: "Run an example command",
Action: func(c *cli.Context) error {
fmt.Println("This is an example command")
return nil
},
}
}
// add commands here