Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
silence errors and use custom error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
aavshr committed Sep 15, 2023
1 parent f4943fb commit 2d15ddf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ Complete documentation available at %s`, utils.DocsUrl),
// while calling the Execute function in the main.go file.
cmd.SilenceUsage = true

// This will prevent the error message from being displayed when an error
// We will handle printing the error message ourselves.
// Each subcommand must use RunE instead of Run.
cmd.SilenceErrors = true

return cmd
}
7 changes: 4 additions & 3 deletions cmd/utils/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ const (
)

var (
SpaceVersion string = "dev"
DevPort int = 4200
Platform string
SpaceVersion = "dev"
DevPort = 4200
Client = api.NewDetaClient(SpaceVersion, Platform)
Logger = log.New(os.Stderr, "", 0)
Logger = log.New(os.Stdout, "", 0)
StdErrLogger = log.New(os.Stderr, "", 0)
)

func IsPortActive(port int) bool {
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package main

import (
"github.com/deta/space/cmd/utils"
"github.com/deta/space/pkg/components/emoji"
"github.com/deta/space/pkg/components/styles"
"os"

"github.com/deta/space/cmd"
)

func main() {
if err := cmd.NewSpaceCmd().Execute(); err != nil {
utils.StdErrLogger.Println(styles.Errorf("%s Error: %v", emoji.ErrorExclamation, err))
os.Exit(1)
}
}

0 comments on commit 2d15ddf

Please sign in to comment.