delegate splash to plugin

This commit is contained in:
Aeterne Satiatus
2020-01-10 18:05:46 +00:00
parent df3d3649ae
commit 568fa8104e
2 changed files with 27 additions and 20 deletions

21
gosh.go
View File

@@ -41,7 +41,6 @@ func New() *Goshell {
// Init initializes the shell with the given context
func (gosh *Goshell) Init(ctx context.Context) error {
gosh.ctx = ctx
gosh.printSplash()
return gosh.loadCommands()
}
@@ -85,24 +84,6 @@ func (gosh *Goshell) loadCommands() error {
return nil
}
// TODO delegate splash to a plugin
func (gosh *Goshell) printSplash() {
fmt.Println(`
888
888
888
.d88b. .d88b. .d8888b 88888b.
d88P"88bd88""88b88K 888 "88b
888 888888 888"Y8888b.888 888
Y88b 888Y88..88P X88888 888
"Y88888 "Y88P" 88888P'888 888
888
Y8b d88P
"Y88P"
`)
}
// Open opens the shell for the given reader
func (gosh *Goshell) Open(r *bufio.Reader) {
loopCtx := gosh.ctx
@@ -196,7 +177,7 @@ func main() {
shell := New()
if err := shell.Init(ctx); err != nil {
fmt.Print("\n\nfailed to initialize:", err)
fmt.Println("\n\nfailed to initialize:\n", err)
os.Exit(1)
}

26
plugins/00_splash.go Normal file
View File

@@ -0,0 +1,26 @@
package main
// this is on the back burner, not needed at the moment
import (
"context"
"fmt"
"github.com/Merith-TK/gosh/api"
)
type splashCmd string
type splashCmds struct{}
func (t *splashCmds) Init(ctx context.Context) error {
// to set your splash, modify the text in the println statement below, multiline is supported
fmt.Println(`-------------------------`)
return nil
}
func (t *splashCmds) Registry() map[string]api.Command {
return map[string]api.Command{}
}
var Commands splashCmds