From a000c6cd84bc134d515005767c323e6c2b2702d1 Mon Sep 17 00:00:00 2001 From: IngCr3at1on Date: Thu, 1 Nov 2018 20:37:17 -0500 Subject: [PATCH] Move commands out of internal package and fix my bad formatting with x5424 --- _example/main.go | 7 +++---- {internal/commands => commands}/commands.go | 0 {internal/commands => commands}/sed/sed.go | 2 +- graceless.go | 8 ++++---- internal/hello.go | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) rename {internal/commands => commands}/commands.go (100%) rename {internal/commands => commands}/sed/sed.go (96%) diff --git a/_example/main.go b/_example/main.go index a4a2769..b0eef24 100644 --- a/_example/main.go +++ b/_example/main.go @@ -17,7 +17,7 @@ import ( "github.com/justanotherorganization/l5424/x5424" // Import the commands we want to be registered. - _ "github.com/justanotherorganization/graceless/internal/commands/sed" + _ "github.com/justanotherorganization/graceless/commands/sed" ) var ( @@ -49,7 +49,7 @@ func init() { } if slackToken == "" { - logger.Log(x5424.Severity, l5424.EmergencyLvl, "Slack token must be set") + logger.Log(x5424.Severity, l5424.EmergencyLvl, "Slack token must be set\n") os.Exit(1) } @@ -108,13 +108,12 @@ func main() { case <-ctx.Done(): return case <-signals: - logger.Log(x5424.Severity, l5424.InfoLvl, "Exiting...") cancel() return case err := <-errCh: if err != nil { // For now treat all errors as non-fatal. - logger.Log(x5424.Severity, l5424.ErrorLvl, err) + logger.Log(x5424.Severity, l5424.ErrorLvl, err, "\n") } } } diff --git a/internal/commands/commands.go b/commands/commands.go similarity index 100% rename from internal/commands/commands.go rename to commands/commands.go diff --git a/internal/commands/sed/sed.go b/commands/sed/sed.go similarity index 96% rename from internal/commands/sed/sed.go rename to commands/sed/sed.go index 58124d1..6ea1e2e 100644 --- a/internal/commands/sed/sed.go +++ b/commands/sed/sed.go @@ -7,7 +7,7 @@ import ( "os/exec" "strings" - cmds "github.com/justanotherorganization/graceless/internal/commands" + cmds "github.com/justanotherorganization/graceless/commands" "github.com/justanotherorganization/justanotherbotkit/commands" "github.com/justanotherorganization/justanotherbotkit/transport" "github.com/pkg/errors" diff --git a/graceless.go b/graceless.go index 06eb2aa..fc8b590 100644 --- a/graceless.go +++ b/graceless.go @@ -4,9 +4,9 @@ import ( "context" "strings" + cmds "github.com/justanotherorganization/graceless/commands" "github.com/justanotherorganization/graceless/config" "github.com/justanotherorganization/graceless/internal" - cmds "github.com/justanotherorganization/graceless/internal/commands" "github.com/justanotherorganization/justanotherbotkit/commands" "github.com/justanotherorganization/justanotherbotkit/proto" "github.com/justanotherorganization/justanotherbotkit/transport" @@ -41,7 +41,7 @@ func (g *Graceless) Start(ctx context.Context, cancel context.CancelFunc, errCh startMsg += " in safemode" } - g.config.Log(x5424.Severity, l5424.InfoLvl, startMsg) + g.config.Log(x5424.Severity, l5424.InfoLvl, startMsg, "\n") // Start building our database (as early as possible). if !g.Safemode() { @@ -212,8 +212,8 @@ func (g *Graceless) Start(ctx context.Context, cancel context.CancelFunc, errCh } } - g.config.Log(x5424.Severity, l5424.InfoLvl, "Shutting down...") - g.config.Log(x5424.Severity, l5424.InfoLvl, "Goodbye") + g.config.Log(x5424.Severity, l5424.InfoLvl, "Shutting down...\n") + g.config.Log(x5424.Severity, l5424.InfoLvl, "Goodbye\n") } // Safemode returns whather we are currently running in safemode. diff --git a/internal/hello.go b/internal/hello.go index add5f25..4024f6b 100644 --- a/internal/hello.go +++ b/internal/hello.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" + "github.com/justanotherorganization/graceless/commands" "github.com/justanotherorganization/graceless/config" - "github.com/justanotherorganization/graceless/internal/commands" "github.com/justanotherorganization/justanotherbotkit/transport" "github.com/pkg/errors" )