feat: some basic commands

This commit is contained in:
2026-02-05 20:41:35 -05:00
parent 22e8a99362
commit 7750d8615f
8 changed files with 274 additions and 54 deletions

View File

@@ -1,18 +0,0 @@
// Package "cli" provides miscellaneous helper functions.
package cli
import (
"fmt"
"os"
)
// A helper function to handle errors in the program. If it is given an error,
// the program will exist, and print the error.
func HandleError(err error) {
if err == nil {
return
}
fmt.Fprintln(os.Stderr, "ERROR:", err)
os.Exit(1)
}

View File

@@ -2,6 +2,8 @@ package registry
import (
"fmt"
"iter"
"maps"
"git.maximhutz.com/max/lambda/internal/cli"
)
@@ -63,7 +65,7 @@ func (r *Registry) MustAddEngine(e cli.Engine) {
}
}
func (r *Registry) GetEngine(name string) (cli.Engine, error) {
func (r Registry) GetEngine(name string) (cli.Engine, error) {
e, ok := r.engines[name]
if !ok {
return nil, fmt.Errorf("engine '%s' not found", name)
@@ -72,6 +74,10 @@ func (r *Registry) GetEngine(name string) (cli.Engine, error) {
return e, nil
}
func (r Registry) ListEngines() iter.Seq[cli.Engine] {
return maps.Values(r.engines)
}
func (r *Registry) GetDefaultEngine(id string) (cli.Engine, error) {
for _, engine := range r.engines {
if engine.InType() == id {