enbas/internal/executor/executor.go
Dan Anglin 40df5e53fe
checkpoint: see body
- moved InvalidListRepliesPolicyError to the model package
- cleaned up some code there in regards to the list replies policy enum type
- cleaned up error messages sent back to the user
- print error messages to standard error os.Stderr
2024-06-02 08:50:47 +01:00

25 lines
499 B
Go

// SPDX-FileCopyrightText: 2024 Dan Anglin <d.n.i.anglin@gmail.com>
//
// SPDX-License-Identifier: GPL-3.0-or-later
package executor
import "fmt"
type Executor interface {
Name() string
Parse(args []string) error
Execute() error
}
func Execute(executor Executor, args []string) error {
if err := executor.Parse(args); err != nil {
return fmt.Errorf("parsing error: %w", err)
}
if err := executor.Execute(); err != nil {
return fmt.Errorf("execution error: %w", err)
}
return nil
}