Base application setup
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 36s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 36s
Signed-off-by: Jan Tytgat <jan.tytgat@corelayer.eu>
This commit is contained in:
38
pkg/application/application.go
Normal file
38
pkg/application/application.go
Normal file
@ -0,0 +1,38 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user