mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Some code improvements
* Some assignments simplified by using assignment operators * Rewrite switch statement with only one case as if. * Rewrite if-else chain as a switch statement. * go fmt `modules/todoist/project.go` file.
This commit is contained in:
parent
c050292a8d
commit
f0771cd013
@ -148,8 +148,8 @@ func (common *Common) SigilStr(len, pos int, width int) string {
|
||||
|
||||
if len > 1 {
|
||||
sigils = strings.Repeat(common.Sigils.Paging.Normal, pos)
|
||||
sigils = sigils + common.Sigils.Paging.Selected
|
||||
sigils = sigils + strings.Repeat(common.Sigils.Paging.Normal, len-1-pos)
|
||||
sigils += common.Sigils.Paging.Selected
|
||||
sigils += strings.Repeat(common.Sigils.Paging.Normal, len-1-pos)
|
||||
|
||||
sigils = "[lightblue]" + fmt.Sprintf(common.RightAlignFormat(width), sigils) + "[white]"
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ func (list *Checklist) Update(text string) {
|
||||
|
||||
// Prev selects the previous item UP in the checklist
|
||||
func (list *Checklist) Prev() {
|
||||
list.selected = list.selected - 1
|
||||
list.selected--
|
||||
if list.selected < 0 {
|
||||
list.selected = len(list.Items) - 1
|
||||
}
|
||||
@ -148,7 +148,7 @@ func (list *Checklist) Prev() {
|
||||
|
||||
// Next selects the next item DOWN in the checklist
|
||||
func (list *Checklist) Next() {
|
||||
list.selected = list.selected + 1
|
||||
list.selected++
|
||||
if list.selected >= len(list.Items) {
|
||||
list.selected = 0
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ func (widget *Widget) contentFrom(items []Item) string {
|
||||
|
||||
str := ""
|
||||
for _, item := range items {
|
||||
str = str + widget.format(item)
|
||||
str += widget.format(item)
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -56,7 +56,7 @@ func (widget *Widget) contentFrom(builds []*Build) string {
|
||||
return str
|
||||
}
|
||||
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
"[%s] %s-%d (%s) [white]%s\n",
|
||||
buildColor(build),
|
||||
build.Reponame,
|
||||
|
@ -19,7 +19,7 @@ func (widget *Widget) display(clocks []Clock, dateFormat string, timeFormat stri
|
||||
rowColor = widget.settings.colors.rows.even
|
||||
}
|
||||
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
" [%s]%-12s %-10s %7s[white]\n",
|
||||
rowColor,
|
||||
clock.Label,
|
||||
|
@ -60,7 +60,7 @@ func (widget *Widget) contentFrom(positions *AllPositionsResponse) string {
|
||||
totalFiat += positions.PositionList[i].HoldingValueFiat
|
||||
|
||||
if widget.settings.displayHoldings {
|
||||
res = res + fmt.Sprintf(
|
||||
res += fmt.Sprintf(
|
||||
"[%s]%-6s - %5.2f ([%s]%.3fk [%s]%.2f%s)\n",
|
||||
widget.settings.colors.name,
|
||||
positions.PositionList[i].Coin,
|
||||
@ -72,7 +72,7 @@ func (widget *Widget) contentFrom(positions *AllPositionsResponse) string {
|
||||
"%",
|
||||
)
|
||||
} else {
|
||||
res = res + fmt.Sprintf(
|
||||
res += fmt.Sprintf(
|
||||
"[%s]%-6s - %5.2f ([%s]%.2f%s)\n",
|
||||
widget.settings.colors.name,
|
||||
positions.PositionList[i].Coin,
|
||||
@ -85,7 +85,7 @@ func (widget *Widget) contentFrom(positions *AllPositionsResponse) string {
|
||||
}
|
||||
|
||||
if widget.settings.displayHoldings {
|
||||
res = res + fmt.Sprintf("\n[%s]Total value: $%.3fk", "green", totalFiat/1000)
|
||||
res += fmt.Sprintf("\n[%s]Total value: $%.3fk", "green", totalFiat/1000)
|
||||
}
|
||||
|
||||
return res
|
||||
|
@ -48,8 +48,7 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
for _, monitor := range monitors {
|
||||
state := *monitor.OverallState
|
||||
switch state {
|
||||
case "Alert":
|
||||
if state == "Alert" {
|
||||
triggeredMonitors = append(triggeredMonitors, monitor)
|
||||
}
|
||||
}
|
||||
@ -74,7 +73,7 @@ func (widget *Widget) contentFrom(triggeredMonitors []datadog.Monitor) string {
|
||||
var str string
|
||||
|
||||
if len(triggeredMonitors) > 0 {
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
" %s\n",
|
||||
"[red]Triggered Monitors[white]",
|
||||
)
|
||||
@ -87,7 +86,7 @@ func (widget *Widget) contentFrom(triggeredMonitors []datadog.Monitor) string {
|
||||
) + "\n"
|
||||
}
|
||||
} else {
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
" %s\n",
|
||||
"[green]No Triggered Monitors[white]",
|
||||
)
|
||||
|
@ -63,14 +63,14 @@ func (widget *Widget) contentFrom(calEvents []*CalEvent) string {
|
||||
title,
|
||||
)
|
||||
|
||||
str = str + fmt.Sprintf("%s %s%s\n",
|
||||
str += fmt.Sprintf("%s %s%s\n",
|
||||
lineOne,
|
||||
widget.location(calEvent),
|
||||
widget.timeUntil(calEvent),
|
||||
)
|
||||
|
||||
if (widget.location(calEvent) != "") || (widget.timeUntil(calEvent) != "") {
|
||||
str = str + "\n"
|
||||
str += "\n"
|
||||
}
|
||||
|
||||
prevEvent = calEvent
|
||||
|
@ -16,14 +16,14 @@ func (widget *Widget) display() {
|
||||
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.GerritProjects), widget.Idx, width) + "\n"
|
||||
str = str + " [red]Stats[white]\n"
|
||||
str = str + widget.displayStats(project)
|
||||
str = str + "\n"
|
||||
str = str + " [red]Open Incoming Reviews[white]\n"
|
||||
str = str + widget.displayMyIncomingReviews(project, widget.settings.username)
|
||||
str = str + "\n"
|
||||
str = str + " [red]My Outgoing Reviews[white]\n"
|
||||
str = str + widget.displayMyOutgoingReviews(project, widget.settings.username)
|
||||
str += " [red]Stats[white]\n"
|
||||
str += widget.displayStats(project)
|
||||
str += "\n"
|
||||
str += " [red]Open Incoming Reviews[white]\n"
|
||||
str += widget.displayMyIncomingReviews(project, widget.settings.username)
|
||||
str += "\n"
|
||||
str += " [red]My Outgoing Reviews[white]\n"
|
||||
str += widget.displayMyOutgoingReviews(project, widget.settings.username)
|
||||
|
||||
widget.Redraw(title, str, false)
|
||||
}
|
||||
@ -35,7 +35,7 @@ func (widget *Widget) displayMyIncomingReviews(project *GerritProject, username
|
||||
|
||||
str := ""
|
||||
for idx, r := range project.IncomingReviews {
|
||||
str = str + fmt.Sprintf(" [%s] [green]%d[white] [%s] %s\n", widget.rowColor(idx), r.Number, widget.rowColor(idx), r.Subject)
|
||||
str += fmt.Sprintf(" [%s] [green]%d[white] [%s] %s\n", widget.rowColor(idx), r.Number, widget.rowColor(idx), r.Subject)
|
||||
}
|
||||
|
||||
return str
|
||||
@ -48,7 +48,7 @@ func (widget *Widget) displayMyOutgoingReviews(project *GerritProject, username
|
||||
|
||||
str := ""
|
||||
for idx, r := range project.OutgoingReviews {
|
||||
str = str + fmt.Sprintf(" [%s] [green]%d[white] [%s] %s\n", widget.rowColor(idx+len(project.IncomingReviews)), r.Number, widget.rowColor(idx+len(project.IncomingReviews)), r.Subject)
|
||||
str += fmt.Sprintf(" [%s] [green]%d[white] [%s] %s\n", widget.rowColor(idx+len(project.IncomingReviews)), r.Number, widget.rowColor(idx+len(project.IncomingReviews)), r.Subject)
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -97,7 +97,7 @@ func (widget *Widget) HelpText() string {
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) nextProject() {
|
||||
widget.Idx = widget.Idx + 1
|
||||
widget.Idx++
|
||||
widget.unselect()
|
||||
if widget.Idx == len(widget.GerritProjects) {
|
||||
widget.Idx = 0
|
||||
@ -107,7 +107,7 @@ func (widget *Widget) nextProject() {
|
||||
}
|
||||
|
||||
func (widget *Widget) prevProject() {
|
||||
widget.Idx = widget.Idx - 1
|
||||
widget.Idx--
|
||||
if widget.Idx < 0 {
|
||||
widget.Idx = len(widget.GerritProjects) - 1
|
||||
}
|
||||
|
@ -17,25 +17,24 @@ func (widget *Widget) display() {
|
||||
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.GitRepos), widget.Idx, width) + "\n"
|
||||
str = str + " [red]Branch[white]\n"
|
||||
str = str + fmt.Sprintf(" %s", repoData.Branch)
|
||||
str = str + "\n"
|
||||
str = str + widget.formatChanges(repoData.ChangedFiles)
|
||||
str = str + "\n"
|
||||
str = str + widget.formatCommits(repoData.Commits)
|
||||
str += " [red]Branch[white]\n"
|
||||
str += fmt.Sprintf(" %s", repoData.Branch)
|
||||
str += "\n"
|
||||
str += widget.formatChanges(repoData.ChangedFiles)
|
||||
str += "\n"
|
||||
str += widget.formatCommits(repoData.Commits)
|
||||
|
||||
widget.Redraw(title, str, false)
|
||||
}
|
||||
|
||||
func (widget *Widget) formatChanges(data []string) string {
|
||||
str := ""
|
||||
str = str + " [red]Changed Files[white]\n"
|
||||
str := " [red]Changed Files[white]\n"
|
||||
|
||||
if len(data) == 1 {
|
||||
str = str + " [grey]none[white]\n"
|
||||
str += " [grey]none[white]\n"
|
||||
} else {
|
||||
for _, line := range data {
|
||||
str = str + widget.formatChange(line)
|
||||
str += widget.formatChange(line)
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,11 +65,10 @@ func (widget *Widget) formatChange(line string) string {
|
||||
}
|
||||
|
||||
func (widget *Widget) formatCommits(data []string) string {
|
||||
str := ""
|
||||
str = str + " [red]Recent Commits[white]\n"
|
||||
str := " [red]Recent Commits[white]\n"
|
||||
|
||||
for _, line := range data {
|
||||
str = str + widget.formatCommit(line)
|
||||
str += widget.formatCommit(line)
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -16,14 +16,14 @@ func (widget *Widget) display() {
|
||||
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.GithubRepos), widget.Idx, width) + "\n"
|
||||
str = str + " [red]Stats[white]\n"
|
||||
str = str + widget.displayStats(repo)
|
||||
str = str + "\n"
|
||||
str = str + " [red]Open Review Requests[white]\n"
|
||||
str = str + widget.displayMyReviewRequests(repo, widget.settings.username)
|
||||
str = str + "\n"
|
||||
str = str + " [red]My Pull Requests[white]\n"
|
||||
str = str + widget.displayMyPullRequests(repo, widget.settings.username)
|
||||
str += " [red]Stats[white]\n"
|
||||
str += widget.displayStats(repo)
|
||||
str += "\n"
|
||||
str += " [red]Open Review Requests[white]\n"
|
||||
str += widget.displayMyReviewRequests(repo, widget.settings.username)
|
||||
str += "\n"
|
||||
str += " [red]My Pull Requests[white]\n"
|
||||
str += widget.displayMyPullRequests(repo, widget.settings.username)
|
||||
|
||||
widget.TextWidget.Redraw(title, str, false)
|
||||
}
|
||||
@ -37,7 +37,7 @@ func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) s
|
||||
|
||||
str := ""
|
||||
for _, pr := range prs {
|
||||
str = str + fmt.Sprintf(" %s[green]%4d[white] %s\n", widget.mergeString(pr), *pr.Number, *pr.Title)
|
||||
str += fmt.Sprintf(" %s[green]%4d[white] %s\n", widget.mergeString(pr), *pr.Number, *pr.Title)
|
||||
}
|
||||
|
||||
return str
|
||||
@ -52,7 +52,7 @@ func (widget *Widget) displayMyReviewRequests(repo *GithubRepo, username string)
|
||||
|
||||
str := ""
|
||||
for _, pr := range prs {
|
||||
str = str + fmt.Sprintf(" [green]%4d[white] %s\n", *pr.Number, *pr.Title)
|
||||
str += fmt.Sprintf(" [green]%4d[white] %s\n", *pr.Number, *pr.Title)
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -16,14 +16,14 @@ func (widget *Widget) display() {
|
||||
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.GitlabProjects), widget.Idx, width) + "\n"
|
||||
str = str + " [red]Stats[white]\n"
|
||||
str = str + widget.displayStats(project)
|
||||
str = str + "\n"
|
||||
str = str + " [red]Open Approval Requests[white]\n"
|
||||
str = str + widget.displayMyApprovalRequests(project, widget.settings.username)
|
||||
str = str + "\n"
|
||||
str = str + " [red]My Merge Requests[white]\n"
|
||||
str = str + widget.displayMyMergeRequests(project, widget.settings.username)
|
||||
str += " [red]Stats[white]\n"
|
||||
str += widget.displayStats(project)
|
||||
str += "\n"
|
||||
str += " [red]Open Approval Requests[white]\n"
|
||||
str += widget.displayMyApprovalRequests(project, widget.settings.username)
|
||||
str += "\n"
|
||||
str += " [red]My Merge Requests[white]\n"
|
||||
str += widget.displayMyMergeRequests(project, widget.settings.username)
|
||||
widget.Redraw(title, str, false)
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ func (widget *Widget) displayMyMergeRequests(project *GitlabProject, username st
|
||||
|
||||
str := ""
|
||||
for _, mr := range mrs {
|
||||
str = str + fmt.Sprintf(" [green]%4d[white] %s\n", mr.IID, mr.Title)
|
||||
str += fmt.Sprintf(" [green]%4d[white] %s\n", mr.IID, mr.Title)
|
||||
}
|
||||
|
||||
return str
|
||||
@ -51,7 +51,7 @@ func (widget *Widget) displayMyApprovalRequests(project *GitlabProject, username
|
||||
|
||||
str := ""
|
||||
for _, mr := range mrs {
|
||||
str = str + fmt.Sprintf(" [green]%4d[white] %s\n", mr.IID, mr.Title)
|
||||
str += fmt.Sprintf(" [green]%4d[white] %s\n", mr.IID, mr.Title)
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -56,7 +56,7 @@ func (widget *Widget) Refresh() {
|
||||
}
|
||||
|
||||
func (widget *Widget) Next() {
|
||||
widget.Idx = widget.Idx + 1
|
||||
widget.Idx++
|
||||
if widget.Idx == len(widget.GitlabProjects) {
|
||||
widget.Idx = 0
|
||||
}
|
||||
@ -65,7 +65,7 @@ func (widget *Widget) Next() {
|
||||
}
|
||||
|
||||
func (widget *Widget) Prev() {
|
||||
widget.Idx = widget.Idx - 1
|
||||
widget.Idx--
|
||||
if widget.Idx < 0 {
|
||||
widget.Idx = len(widget.GitlabProjects) - 1
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func (widget *Widget) display() {
|
||||
func (widget *Widget) contentFrom(messages []Message) string {
|
||||
var str string
|
||||
for idx, message := range messages {
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
`["%d"][%s] [blue]%s [lightslategray]%s: [%s]%s [aqua]%s[""]`,
|
||||
idx,
|
||||
widget.RowColor(idx),
|
||||
@ -94,7 +94,7 @@ func (widget *Widget) contentFrom(messages []Message) string {
|
||||
message.Sent.Format("Jan 02, 15:04 MST"),
|
||||
)
|
||||
|
||||
str = str + "\n"
|
||||
str += "\n"
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -43,7 +43,7 @@ func (widget *Widget) contentFrom(valueRanges []*sheets.ValueRange) string {
|
||||
|
||||
cells := wtf.ToStrs(widget.settings.cellNames)
|
||||
for i := 0; i < len(valueRanges); i++ {
|
||||
res = res + fmt.Sprintf("%s\t[%s]%s\n", cells[i], widget.settings.colors.values, valueRanges[i].Values[0][0])
|
||||
res += fmt.Sprintf("%s\t[%s]%s\n", cells[i], widget.settings.colors.values, valueRanges[i].Values[0][0])
|
||||
}
|
||||
|
||||
return res
|
||||
|
@ -83,7 +83,7 @@ func (widget *Widget) contentFrom(stories []Story) string {
|
||||
|
||||
u, _ := url.Parse(story.URL)
|
||||
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
`["%d"][""][%s]%2d. %s [lightblue](%s)[white][""]`,
|
||||
idx,
|
||||
widget.RowColor(idx),
|
||||
@ -92,7 +92,7 @@ func (widget *Widget) contentFrom(stories []Story) string {
|
||||
strings.TrimPrefix(u.Host, "www."),
|
||||
)
|
||||
|
||||
str = str + "\n"
|
||||
str += "\n"
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -46,8 +46,8 @@ func (widget *Widget) Create(jenkinsURL string, username string, apiKey string)
|
||||
return view, nil
|
||||
}
|
||||
|
||||
func ensureLastSlash(URL string) string {
|
||||
return strings.TrimRight(URL, "/") + "/"
|
||||
func ensureLastSlash(url string) string {
|
||||
return strings.TrimRight(url, "/") + "/"
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -75,7 +75,7 @@ func (widget *Widget) contentFrom(view *View) string {
|
||||
var validID = regexp.MustCompile(widget.settings.jobNameRegex)
|
||||
|
||||
if validID.MatchString(job.Name) {
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
`["%d"][%s] [%s]%-6s[white][""]`,
|
||||
idx,
|
||||
widget.RowColor(idx),
|
||||
@ -83,7 +83,7 @@ func (widget *Widget) contentFrom(view *View) string {
|
||||
job.Name,
|
||||
)
|
||||
|
||||
str = str + "\n"
|
||||
str += "\n"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ func (widget *Widget) contentFrom(searchResult *SearchResult) string {
|
||||
)
|
||||
|
||||
_, _, w, _ := widget.View.GetInnerRect()
|
||||
fmtStr = fmtStr + wtf.PadRow(len(issue.IssueFields.Summary), w+1)
|
||||
fmtStr += wtf.PadRow(len(issue.IssueFields.Summary), w+1)
|
||||
|
||||
str = str + fmtStr + "\n"
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ func (widget *Widget) contentFrom(logLines []string) string {
|
||||
chunks := strings.Split(line, " ")
|
||||
|
||||
if len(chunks) >= 4 {
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
"[green]%s[white] [yellow]%s[white] %s\n",
|
||||
chunks[0],
|
||||
chunks[1],
|
||||
|
@ -17,25 +17,24 @@ func (widget *Widget) display() {
|
||||
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.Data), widget.Idx, width) + "\n"
|
||||
str = str + " [red]Branch:Bookmark[white]\n"
|
||||
str = str + fmt.Sprintf(" %s:%s\n", repoData.Branch, repoData.Bookmark)
|
||||
str = str + "\n"
|
||||
str = str + widget.formatChanges(repoData.ChangedFiles)
|
||||
str = str + "\n"
|
||||
str = str + widget.formatCommits(repoData.Commits)
|
||||
str += " [red]Branch:Bookmark[white]\n"
|
||||
str += fmt.Sprintf(" %s:%s\n", repoData.Branch, repoData.Bookmark)
|
||||
str += "\n"
|
||||
str += widget.formatChanges(repoData.ChangedFiles)
|
||||
str += "\n"
|
||||
str += widget.formatCommits(repoData.Commits)
|
||||
|
||||
widget.Redraw(title, str, false)
|
||||
}
|
||||
|
||||
func (widget *Widget) formatChanges(data []string) string {
|
||||
str := ""
|
||||
str = str + " [red]Changed Files[white]\n"
|
||||
str := " [red]Changed Files[white]\n"
|
||||
|
||||
if len(data) == 1 {
|
||||
str = str + " [grey]none[white]\n"
|
||||
str += " [grey]none[white]\n"
|
||||
} else {
|
||||
for _, line := range data {
|
||||
str = str + widget.formatChange(line)
|
||||
str += widget.formatChange(line)
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,11 +65,10 @@ func (widget *Widget) formatChange(line string) string {
|
||||
}
|
||||
|
||||
func (widget *Widget) formatCommits(data []string) string {
|
||||
str := ""
|
||||
str = str + " [red]Recent Commits[white]\n"
|
||||
str := " [red]Recent Commits[white]\n"
|
||||
|
||||
for _, line := range data {
|
||||
str = str + widget.formatCommit(line)
|
||||
str += widget.formatCommit(line)
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -84,7 +84,8 @@ func (widget *Widget) nbascore() string {
|
||||
quarter := 0.
|
||||
activate := false
|
||||
for keyGame, team := range game.(map[string]interface{}) { // assertion
|
||||
if keyGame == "vTeam" || keyGame == "hTeam" {
|
||||
switch keyGame {
|
||||
case "vTeam", "hTeam":
|
||||
for keyTeam, stat := range team.(map[string]interface{}) {
|
||||
if keyTeam == "triCode" {
|
||||
if keyGame == "vTeam" {
|
||||
@ -100,13 +101,13 @@ func (widget *Widget) nbascore() string {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if keyGame == "period" {
|
||||
case "period":
|
||||
for keyTeam, stat := range team.(map[string]interface{}) {
|
||||
if keyTeam == "current" {
|
||||
quarter = stat.(float64)
|
||||
}
|
||||
}
|
||||
} else if keyGame == "isGameActivated" {
|
||||
case "isGameActivated":
|
||||
activate = team.(bool)
|
||||
}
|
||||
}
|
||||
@ -114,16 +115,17 @@ func (widget *Widget) nbascore() string {
|
||||
hNum, _ := strconv.Atoi(hScore)
|
||||
hColor := ""
|
||||
if quarter != 0 { // Compare the score
|
||||
if vNum > hNum {
|
||||
switch {
|
||||
case vNum > hNum:
|
||||
vTeam = "[orange]" + vTeam
|
||||
} else if hNum > vNum {
|
||||
case hNum > vNum:
|
||||
// hScore = "[orange]" + hScore
|
||||
hColor = "[orange]" // For correct padding
|
||||
hTeam = hTeam + "[white]"
|
||||
} else {
|
||||
hTeam += "[white]"
|
||||
default:
|
||||
vTeam = "[orange]" + vTeam
|
||||
hColor = "[orange]"
|
||||
hTeam = hTeam + "[white]"
|
||||
hTeam += "[white]"
|
||||
}
|
||||
}
|
||||
qColor := "[white]"
|
||||
|
@ -73,7 +73,7 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string {
|
||||
revLen = len(deploy.Revision)
|
||||
}
|
||||
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
" [green]%s[%s] %s %-.16s[white]\n",
|
||||
deploy.Revision[0:revLen],
|
||||
lineColor,
|
||||
|
@ -61,8 +61,8 @@ func (widget *Widget) contentFrom(onCallResponses []*OnCallResponse) string {
|
||||
msg = fmt.Sprintf(" %s\n\n", strings.Join(wtf.NamesFromEmails(data.OnCallData.Recipients), ", "))
|
||||
}
|
||||
|
||||
str = str + widget.cleanScheduleName(data.OnCallData.Parent.Name)
|
||||
str = str + msg
|
||||
str += widget.cleanScheduleName(data.OnCallData.Parent.Name)
|
||||
str += msg
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -48,10 +48,10 @@ func (widget *Widget) Refresh() {
|
||||
if err1 != nil || err2 != nil {
|
||||
wrap = true
|
||||
if err1 != nil {
|
||||
content = content + err1.Error()
|
||||
content += err1.Error()
|
||||
}
|
||||
if err2 != nil {
|
||||
content = content + err2.Error()
|
||||
content += err2.Error()
|
||||
}
|
||||
} else {
|
||||
widget.View.SetWrap(false)
|
||||
@ -67,12 +67,12 @@ func (widget *Widget) contentFrom(onCalls []pagerduty.OnCall, incidents []pagerd
|
||||
var str string
|
||||
|
||||
if len(incidents) > 0 {
|
||||
str = str + "[yellow]Incidents[white]\n"
|
||||
str += "[yellow]Incidents[white]\n"
|
||||
for _, incident := range incidents {
|
||||
str = str + fmt.Sprintf("[red]%s[white]\n", incident.Summary)
|
||||
str = str + fmt.Sprintf("Status: %s\n", incident.Status)
|
||||
str = str + fmt.Sprintf("Service: %s\n", incident.Service.Summary)
|
||||
str = str + fmt.Sprintf("Escalation: %s\n", incident.EscalationPolicy.Summary)
|
||||
str += fmt.Sprintf("[red]%s[white]\n", incident.Summary)
|
||||
str += fmt.Sprintf("Status: %s\n", incident.Status)
|
||||
str += fmt.Sprintf("Service: %s\n", incident.Service.Summary)
|
||||
str += fmt.Sprintf("Escalation: %s\n", incident.EscalationPolicy.Summary)
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,14 +99,14 @@ func (widget *Widget) contentFrom(onCalls []pagerduty.OnCall, incidents []pagerd
|
||||
sort.Strings(keys)
|
||||
|
||||
if len(keys) > 0 {
|
||||
str = str + "\n[red] Schedules[white]\n"
|
||||
str += "\n[red] Schedules[white]\n"
|
||||
// Print out policies, and escalation order of users
|
||||
for _, key := range keys {
|
||||
str = str + fmt.Sprintf("\n [green::b]%s\n", key)
|
||||
str += fmt.Sprintf("\n [green::b]%s\n", key)
|
||||
values := tree[key]
|
||||
sort.Sort(ByEscalationLevel(values))
|
||||
for _, item := range values {
|
||||
str = str + fmt.Sprintf(" [white]%d - %s\n", item.EscalationLevel, item.User.Summary)
|
||||
str += fmt.Sprintf(" [white]%d - %s\n", item.EscalationLevel, item.User.Summary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,12 +69,11 @@ func (battery *Battery) parse(data string) string {
|
||||
if s := table["time to empty"]; s == "" {
|
||||
table["time to empty"] = "∞"
|
||||
}
|
||||
str := ""
|
||||
str = str + fmt.Sprintf(" %10s: %s\n", "Charge", battery.formatCharge(table["percentage"]))
|
||||
str = str + fmt.Sprintf(" %10s: %s\n", "Remaining", table["time to empty"])
|
||||
str = str + fmt.Sprintf(" %10s: %s\n", "State", battery.formatState(table["state"]))
|
||||
str := fmt.Sprintf(" %10s: %s\n", "Charge", battery.formatCharge(table["percentage"]))
|
||||
str += fmt.Sprintf(" %10s: %s\n", "Remaining", table["time to empty"])
|
||||
str += fmt.Sprintf(" %10s: %s\n", "State", battery.formatState(table["state"]))
|
||||
if s := table["time to full"]; s != "" {
|
||||
str = str + fmt.Sprintf(" %10s: %s\n", "TimeToFull", table["time to full"])
|
||||
str += fmt.Sprintf(" %10s: %s\n", "TimeToFull", table["time to full"])
|
||||
}
|
||||
batteryState = table["state"]
|
||||
return str
|
||||
|
@ -32,10 +32,9 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.Battery.Refresh()
|
||||
|
||||
content := ""
|
||||
content = content + fmt.Sprintf(" %10s: %s\n", "Source", powerSource())
|
||||
content = content + "\n"
|
||||
content = content + widget.Battery.String()
|
||||
content := fmt.Sprintf(" %10s: %s\n", "Source", powerSource())
|
||||
content += "\n"
|
||||
content += widget.Battery.String()
|
||||
|
||||
widget.Redraw(widget.CommonSettings.Title, content, true)
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ func (widget *Widget) contentFrom(result *Result) string {
|
||||
}
|
||||
for idx, item := range result.Items {
|
||||
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
"[%s] [%s] %s [%s] %s [%s]count: %d [%s]%s\n",
|
||||
widget.RowColor(idx),
|
||||
levelColor(&item),
|
||||
|
@ -42,23 +42,23 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
func (widget *Widget) contentFrom(data *SecurityData) string {
|
||||
str := " [red]WiFi[white]\n"
|
||||
str = str + fmt.Sprintf(" %8s: %s\n", "Network", data.WifiName)
|
||||
str = str + fmt.Sprintf(" %8s: %s\n", "Crypto", data.WifiEncryption)
|
||||
str = str + "\n"
|
||||
str += fmt.Sprintf(" %8s: %s\n", "Network", data.WifiName)
|
||||
str += fmt.Sprintf(" %8s: %s\n", "Crypto", data.WifiEncryption)
|
||||
str += "\n"
|
||||
|
||||
str = str + " [red]Firewall[white]\n"
|
||||
str = str + fmt.Sprintf(" %8s: %4s\n", "Status", data.FirewallEnabled)
|
||||
str = str + fmt.Sprintf(" %8s: %4s\n", "Stealth", data.FirewallStealth)
|
||||
str = str + "\n"
|
||||
str += " [red]Firewall[white]\n"
|
||||
str += fmt.Sprintf(" %8s: %4s\n", "Status", data.FirewallEnabled)
|
||||
str += fmt.Sprintf(" %8s: %4s\n", "Stealth", data.FirewallStealth)
|
||||
str += "\n"
|
||||
|
||||
str = str + " [red]Users[white]\n"
|
||||
str = str + fmt.Sprintf(" %s", strings.Join(data.LoggedInUsers, "\n "))
|
||||
str = str + "\n\n"
|
||||
str += " [red]Users[white]\n"
|
||||
str += fmt.Sprintf(" %s", strings.Join(data.LoggedInUsers, "\n "))
|
||||
str += "\n\n"
|
||||
|
||||
str = str + " [red]DNS[white]\n"
|
||||
str = str + fmt.Sprintf(" %12s\n", data.DnsAt(0))
|
||||
str = str + fmt.Sprintf(" %12s\n", data.DnsAt(1))
|
||||
str = str + "\n"
|
||||
str += " [red]DNS[white]\n"
|
||||
str += fmt.Sprintf(" %12s\n", data.DnsAt(0))
|
||||
str += fmt.Sprintf(" %12s\n", data.DnsAt(1))
|
||||
str += "\n"
|
||||
|
||||
return str
|
||||
}
|
||||
|
@ -112,8 +112,7 @@ func parseWlanNetsh(target string) string {
|
||||
}
|
||||
}
|
||||
for i, token := range words {
|
||||
switch token {
|
||||
case target:
|
||||
if token == target {
|
||||
return words[i+1]
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func (widget *Widget) animation() string {
|
||||
icons := []string{"|", "/", "-", "\\", "|"}
|
||||
next := icons[widget.CurrentIcon]
|
||||
|
||||
widget.CurrentIcon = widget.CurrentIcon + 1
|
||||
widget.CurrentIcon++
|
||||
if widget.CurrentIcon == len(icons) {
|
||||
widget.CurrentIcon = 0
|
||||
}
|
||||
|
@ -76,9 +76,9 @@ func (widget *Widget) display() {
|
||||
text := widget.settings.common.SigilStr(len(widget.Sources), widget.Idx, width) + "\n"
|
||||
|
||||
if widget.settings.format {
|
||||
text = text + widget.formattedText()
|
||||
text += widget.formattedText()
|
||||
} else {
|
||||
text = text + widget.plainText()
|
||||
text += widget.plainText()
|
||||
}
|
||||
|
||||
widget.Redraw(title, text, true)
|
||||
|
@ -20,13 +20,13 @@ func (widget *Widget) display() {
|
||||
offset := 0
|
||||
|
||||
for idx, item := range widget.list.UncheckedItems() {
|
||||
str = str + widget.formattedItemLine(idx, item, widget.list.SelectedItem(), widget.list.LongestLine())
|
||||
str += widget.formattedItemLine(idx, item, widget.list.SelectedItem(), widget.list.LongestLine())
|
||||
newList.Items = append(newList.Items, item)
|
||||
offset++
|
||||
}
|
||||
|
||||
for idx, item := range widget.list.CheckedItems() {
|
||||
str = str + widget.formattedItemLine(idx+offset, item, widget.list.SelectedItem(), widget.list.LongestLine())
|
||||
str += widget.formattedItemLine(idx+offset, item, widget.list.SelectedItem(), widget.list.LongestLine())
|
||||
newList.Items = append(newList.Items, item)
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,12 @@ type Project struct {
|
||||
}
|
||||
|
||||
func NewProject(id int) *Project {
|
||||
// Todoist seems to experience a lot of network issues on their side
|
||||
// If we can't connect, handle it with an empty project until we can
|
||||
// Todoist seems to experience a lot of network issues on their side
|
||||
// If we can't connect, handle it with an empty project until we can
|
||||
project, err := todoist.GetProject(id)
|
||||
if err != nil {
|
||||
return &Project{}
|
||||
}
|
||||
if err != nil {
|
||||
return &Project{}
|
||||
}
|
||||
|
||||
proj := &Project{
|
||||
Project: project,
|
||||
@ -41,7 +41,7 @@ func (proj *Project) isLast() bool {
|
||||
}
|
||||
|
||||
func (proj *Project) up() {
|
||||
proj.index = proj.index - 1
|
||||
proj.index--
|
||||
|
||||
if proj.index < 0 {
|
||||
proj.index = len(proj.tasks) - 1
|
||||
@ -54,7 +54,7 @@ func (proj *Project) down() {
|
||||
return
|
||||
}
|
||||
|
||||
proj.index = proj.index + 1
|
||||
proj.index++
|
||||
if proj.index >= len(proj.tasks) {
|
||||
proj.index = 0
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ func (widget *Widget) contentFrom(builds *Builds) string {
|
||||
var str string
|
||||
for idx, build := range builds.Builds {
|
||||
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
"[%s] [%s] %s-%s (%s) [%s]%s - [blue]%s\n",
|
||||
widget.RowColor(idx),
|
||||
buildColor(&build),
|
||||
|
@ -26,7 +26,7 @@ func GetCards(client *trello.Client, username string, boardName string, lists ma
|
||||
return nil, err
|
||||
}
|
||||
|
||||
searchResult.Total = searchResult.Total + len(cards)
|
||||
searchResult.Total += len(cards)
|
||||
cardArray := make([]TrelloCard, 0)
|
||||
|
||||
for _, card := range cards {
|
||||
|
@ -67,10 +67,10 @@ func (widget *Widget) contentFrom(searchResult *SearchResult) string {
|
||||
str := ""
|
||||
|
||||
for list, cardArray := range searchResult.TrelloCards {
|
||||
str = str + fmt.Sprintf(" [red]%s[white]\n", list)
|
||||
str += fmt.Sprintf(" [red]%s[white]\n", list)
|
||||
|
||||
for _, card := range cardArray {
|
||||
str = str + fmt.Sprintf(" %s[white]\n", card.Name)
|
||||
str += fmt.Sprintf(" %s[white]\n", card.Name)
|
||||
}
|
||||
str = fmt.Sprintf("%s\n", str)
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func (widget *Widget) display() {
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.Sources), widget.Idx, width-2) + "\n"
|
||||
for _, tweet := range tweets {
|
||||
str = str + widget.format(tweet)
|
||||
str += widget.format(tweet)
|
||||
}
|
||||
|
||||
widget.Redraw(title, str, true)
|
||||
|
@ -35,9 +35,9 @@ func (widget *Widget) display() {
|
||||
title = widget.buildTitle(cityData)
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
content = widget.settings.common.SigilStr(len(widget.Data), widget.Idx, width) + "\n"
|
||||
content = content + widget.description(cityData) + "\n\n"
|
||||
content = content + widget.temperatures(cityData) + "\n"
|
||||
content = content + widget.sunInfo(cityData)
|
||||
content += widget.description(cityData) + "\n\n"
|
||||
content += widget.temperatures(cityData) + "\n"
|
||||
content += widget.sunInfo(cityData)
|
||||
}
|
||||
|
||||
widget.Redraw(title, content, setWrap)
|
||||
@ -63,7 +63,7 @@ func (widget *Widget) sunInfo(cityData *owm.CurrentWeatherData) string {
|
||||
func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string {
|
||||
str := fmt.Sprintf("%8s: %4.1f° %s\n", "High", cityData.Main.TempMax, widget.settings.tempUnit)
|
||||
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
"%8s: [%s]%4.1f° %s[white]\n",
|
||||
"Current",
|
||||
widget.settings.colors.current,
|
||||
@ -71,7 +71,7 @@ func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string {
|
||||
widget.settings.tempUnit,
|
||||
)
|
||||
|
||||
str = str + fmt.Sprintf("%8s: %4.1f° %s\n", "Low", cityData.Main.TempMin, widget.settings.tempUnit)
|
||||
str += fmt.Sprintf("%8s: %4.1f° %s\n", "Low", cityData.Main.TempMin, widget.settings.tempUnit)
|
||||
|
||||
return str
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ func (widget *Widget) Refresh() {
|
||||
// Next displays data for the next city data in the list. If the current city is the last
|
||||
// city, it wraps to the first city.
|
||||
func (widget *Widget) Next() {
|
||||
widget.Idx = widget.Idx + 1
|
||||
widget.Idx++
|
||||
if widget.Idx == len(widget.Data) {
|
||||
widget.Idx = 0
|
||||
}
|
||||
@ -79,7 +79,7 @@ func (widget *Widget) Next() {
|
||||
// Prev displays data for the previous city in the list. If the previous city is the first
|
||||
// city, it wraps to the last city.
|
||||
func (widget *Widget) Prev() {
|
||||
widget.Idx = widget.Idx - 1
|
||||
widget.Idx--
|
||||
if widget.Idx < 0 {
|
||||
widget.Idx = len(widget.Data) - 1
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ func (widget *Widget) textContent(items []Ticket) string {
|
||||
|
||||
str := ""
|
||||
for idx, data := range items {
|
||||
str = str + widget.format(data, idx)
|
||||
str += widget.format(data, idx)
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -11,8 +11,7 @@ const modalHeight = 22
|
||||
|
||||
func NewBillboardModal(text string, closeFunc func()) *tview.Frame {
|
||||
keyboardIntercept := func(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch string(event.Rune()) {
|
||||
case "/":
|
||||
if string(event.Rune()) == "/" {
|
||||
closeFunc()
|
||||
return nil
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ func (tracker *FocusTracker) blur(idx int) {
|
||||
}
|
||||
|
||||
func (tracker *FocusTracker) decrement() {
|
||||
tracker.Idx = tracker.Idx - 1
|
||||
tracker.Idx--
|
||||
|
||||
if tracker.Idx < 0 {
|
||||
tracker.Idx = len(tracker.focusables()) - 1
|
||||
@ -216,7 +216,7 @@ func (tracker *FocusTracker) focusState() FocusState {
|
||||
}
|
||||
|
||||
func (tracker *FocusTracker) increment() {
|
||||
tracker.Idx = tracker.Idx + 1
|
||||
tracker.Idx++
|
||||
|
||||
if tracker.Idx == len(tracker.focusables()) {
|
||||
tracker.Idx = 0
|
||||
|
@ -89,12 +89,12 @@ func (widget *KeyboardWidget) HelpText() string {
|
||||
str := "Keyboard commands for " + widget.settings.Module.Type + "\n\n"
|
||||
|
||||
for _, item := range widget.charHelp {
|
||||
str = str + fmt.Sprintf(" [%s]: %s\n", item.Key, item.Text)
|
||||
str += fmt.Sprintf(" [%s]: %s\n", item.Key, item.Text)
|
||||
}
|
||||
str = str + "\n\n"
|
||||
str += "\n\n"
|
||||
|
||||
for _, item := range widget.keyHelp {
|
||||
str = str + fmt.Sprintf(" [%-*s]: %s\n", widget.maxKey, item.Key, item.Text)
|
||||
str += fmt.Sprintf(" [%-*s]: %s\n", widget.maxKey, item.Key, item.Text)
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -45,7 +45,7 @@ func (widget *MultiSourceWidget) CurrentSource() string {
|
||||
// Next displays the next source in the source list. If the current source is the last
|
||||
// source it wraps around to the first source
|
||||
func (widget *MultiSourceWidget) NextSource() {
|
||||
widget.Idx = widget.Idx + 1
|
||||
widget.Idx++
|
||||
if widget.Idx == len(widget.Sources) {
|
||||
widget.Idx = 0
|
||||
}
|
||||
@ -58,7 +58,7 @@ func (widget *MultiSourceWidget) NextSource() {
|
||||
// Prev displays the previous source in the source list. If the current source is the first
|
||||
// source, it wraps around to the last source
|
||||
func (widget *MultiSourceWidget) PrevSource() {
|
||||
widget.Idx = widget.Idx - 1
|
||||
widget.Idx--
|
||||
if widget.Idx < 0 {
|
||||
widget.Idx = len(widget.Sources) - 1
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user