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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user