Skip to content

Commit

Permalink
remove commented code blocks, move appName func to shared package
Browse files Browse the repository at this point in the history
  • Loading branch information
GraysonNull committed Aug 13, 2020
1 parent e8dc5ae commit 4e08ce4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 80 deletions.
21 changes: 2 additions & 19 deletions cmd/preflight/cli/interactive_results.go
Expand Up @@ -5,7 +5,6 @@ import (
"io/ioutil"
"os"
"path"
"strings"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -100,7 +99,7 @@ func drawHeader(preflightName string) {
termWidth, _ := ui.TerminalDimensions()

title := widgets.NewParagraph()
title.Text = fmt.Sprintf("%s Preflight Checks", appName(preflightName))
title.Text = fmt.Sprintf("%s Preflight Checks", util.AppName(preflightName))
title.TextStyle.Fg = ui.ColorWhite
title.TextStyle.Bg = ui.ColorClear
title.TextStyle.Modifier = ui.ModifierBold
Expand Down Expand Up @@ -225,7 +224,7 @@ func save(preflightName string, analyzeResults []*analyzerunner.AnalyzeResult) (
os.Remove(filename)
}

results := fmt.Sprintf("%s Preflight Checks\n\n", appName(preflightName))
results := fmt.Sprintf("%s Preflight Checks\n\n", util.AppName(preflightName))
for _, analyzeResult := range analyzeResults {
result := ""

Expand Down Expand Up @@ -274,19 +273,3 @@ func showSaved(filename string) {

isShowingSaved = true
}

func appName(preflightName string) string {
words := strings.Split(strings.Title(strings.Replace(preflightName, "-", " ", -1)), " ")
casedWords := []string{}
for i, word := range words {
if strings.ToLower(word) == "ai" {
casedWords = append(casedWords, "AI")
} else if strings.ToLower(word) == "io" && i > 0 {
casedWords[i-1] += ".io"
} else {
casedWords = append(casedWords, word)
}
}

return strings.Join(casedWords, " ")
}
62 changes: 1 addition & 61 deletions cmd/troubleshoot/cli/interactive_results.go
Expand Up @@ -5,7 +5,6 @@ import (
"io/ioutil"
"os"
"path"
"strings"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -99,7 +98,7 @@ func drawHeader(supportBundleName string) {
termWidth, _ := ui.TerminalDimensions()

title := widgets.NewParagraph()
title.Text = fmt.Sprintf("%s Support Bundle Analysis", appName(supportBundleName))
title.Text = fmt.Sprintf("%s Support Bundle Analysis", util.AppName(supportBundleName))
title.TextStyle.Fg = ui.ColorWhite
title.TextStyle.Bg = ui.ColorClear
title.TextStyle.Modifier = ui.ModifierBold
Expand Down Expand Up @@ -217,49 +216,6 @@ func estimateNumberOfLines(text string, width int) int {
return lines
}

// func drawGrid(analyzeResults []*analyzerunner.AnalyzeResult) {
// termWidth, _ := ui.TerminalDimensions()

// tileWidth := 40
// tileHeight := 10

// columnCount := termWidth / tileWidth

// row := 0
// col := 0

// for _, analyzeResult := range analyzeResults {
// // draw this file

// tile := widgets.NewParagraph()
// tile.Title = analyzeResult.Title
// tile.Text = analyzeResult.Message
// tile.PaddingLeft = 1
// tile.PaddingBottom = 1
// tile.PaddingRight = 1
// tile.PaddingTop = 1

// tile.SetRect(col*tileWidth, row*tileHeight, col*tileWidth+tileWidth, row*tileHeight+tileHeight)

// if analyzeResult.IsFail {
// tile.BorderStyle.Fg = ui.ColorRed
// } else if analyzeResult.IsWarn {
// tile.BorderStyle.Fg = ui.ColorYellow
// } else {
// tile.BorderStyle.Fg = ui.ColorGreen
// }

// ui.Render(tile)

// col++

// if col >= columnCount {
// col = 0
// row++
// }
// }
// }

func showSaved(filename string) {
termWidth, termHeight := ui.TerminalDimensions()

Expand Down Expand Up @@ -316,19 +272,3 @@ func save(analyzeResults []*analyzerunner.AnalyzeResult) (string, error) {

return filename, nil
}

func appName(supportBundleName string) string {
words := strings.Split(strings.Title(strings.Replace(supportBundleName, "-", " ", -1)), " ")
casedWords := []string{}
for i, word := range words {
if strings.ToLower(word) == "ai" {
casedWords = append(casedWords, "AI")
} else if strings.ToLower(word) == "io" && i > 0 {
casedWords[i-1] += ".io"
} else {
casedWords = append(casedWords, word)
}
}

return strings.Join(casedWords, " ")
}
17 changes: 17 additions & 0 deletions cmd/util/util.go
Expand Up @@ -3,6 +3,7 @@ package util
import (
"net/url"
"os"
"strings"
)

func HomeDir() string {
Expand All @@ -20,3 +21,19 @@ func IsURL(str string) bool {

return parsed.Scheme != ""
}

func AppName(name string) string {
words := strings.Split(strings.Title(strings.Replace(name, "-", " ", -1)), " ")
casedWords := []string{}
for i, word := range words {
if strings.ToLower(word) == "ai" {
casedWords = append(casedWords, "AI")
} else if strings.ToLower(word) == "io" && i > 0 {
casedWords[i-1] += ".io"
} else {
casedWords = append(casedWords, word)
}
}

return strings.Join(casedWords, " ")
}

0 comments on commit 4e08ce4

Please sign in to comment.