feat: some basic commands
This commit is contained in:
@@ -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)
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user