Dan Anglin
40df5e53fe
- 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
25 lines
499 B
Go
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
|
|
}
|