Skip to content

Commit

Permalink
fix: constant, cmd and utils
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsm-dev committed Sep 23, 2022
1 parent da8154e commit 15258f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
21 changes: 4 additions & 17 deletions commands/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,18 @@ package commands

import (
"fmt"
"io"
"os"

"github.com/ci-monk/loli/internal/consts"
log "github.com/ci-monk/loli/internal/log"
"github.com/ci-monk/loli/internal/utils"
)

var (
// Out is used to write to information.
Out io.Writer
// Err is used to write errors.
Err io.Writer
)

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by loli main(). It only needs to happen once to the rootCmd.
func Execute() {
outputRender, err := utils.RenderMarkdown(consts.Welcome)
if err != nil {
log.Fatal("Render glamour markdown")
}

fmt.Print(outputRender)
utils.ShowHeader()

if err := rootCmd.Execute(); err != nil {
log.Fatal("Error while executing RootCmd")
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}
4 changes: 1 addition & 3 deletions internal/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ var (
const Welcome = `
Hello there, fellow coders πŸ€–!
If you want access this repository, copy this [link](https://github.com/lpmatos/loli).
Bye! πŸ‘‹πŸ‘‹πŸ‘‹
If you want access this repository, copy this [link](https://github.com/lpmatos/loli). πŸ‘‹
`

// CompletionHelpMessage - return the long description of completion command.
Expand Down
10 changes: 10 additions & 0 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,13 @@ func AnimeIsAdult(isAdult bool) string {
}
return fmt.Sprint(color.RedString("false"))
}

// ShowHeader pretty print header information
func ShowHeader() {
outputRender, err := RenderMarkdown(consts.Welcome)
if err != nil {
fmt.Fprintf(os.Stderr, "Error render glamour markdow: %v\n", err)
os.Exit(1)
}
fmt.Print(outputRender)
}

0 comments on commit 15258f8

Please sign in to comment.