
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 36s
Signed-off-by: Jan Tytgat <jan.tytgat@corelayer.eu>
39 lines
581 B
Go
39 lines
581 B
Go
package application
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type Application interface {
|
|
Start(ctx context.Context) error
|
|
Shutdown() error
|
|
}
|
|
|
|
func New(c Config) (Application, error) {
|
|
var cmd *cobra.Command
|
|
var err error
|
|
if cmd, err = c.getRootCommand(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &application{
|
|
cmd: cmd,
|
|
}, nil
|
|
}
|
|
|
|
type application struct {
|
|
cmd *cobra.Command
|
|
}
|
|
|
|
func (a *application) Start(ctx context.Context) error {
|
|
return a.cmd.ExecuteContext(ctx)
|
|
}
|
|
|
|
func (a *application) Shutdown() error {
|
|
fmt.Println("Shutdown")
|
|
return nil
|
|
}
|