mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Windows things
This commit is contained in:
parent
f6f51799d7
commit
d090a5a1da
1 changed files with 27 additions and 5 deletions
|
|
@ -5,11 +5,31 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var prefix, progressDown, progressDownFinish string
|
||||||
|
|
||||||
|
func initPrefixBecauseWindowsSucksBallsHard() {
|
||||||
|
// dear windows user, please change to a good OS, linux in the best case.
|
||||||
|
// MICROSHIT DOES NOT GET IT DONE TO SHOW THE SYMBOLS IN THE ELSE CLAUSE
|
||||||
|
// CORRECTLY. NOT IN THE CMD NOR POWERSHELL. WHY TF, IT IS ONE OF THE MOST
|
||||||
|
// PROFITABLE COMPANIES ON THIS PLANET AND CANNOT SHOW A PROPER UTF-8 SYMBOL
|
||||||
|
// IN THEIR OWN PRODUCT WHICH GETS USED MILLION TIMES A DAY
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
prefix = "=>"
|
||||||
|
progressDown = "|"
|
||||||
|
progressDownFinish = "->"
|
||||||
|
} else {
|
||||||
|
prefix = "➞"
|
||||||
|
progressDown = "↓"
|
||||||
|
progressDownFinish = "↳"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type progress struct {
|
type progress struct {
|
||||||
message string
|
message string
|
||||||
stop bool
|
stop bool
|
||||||
|
|
@ -28,7 +48,9 @@ type logger struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLogger(debug, info, err bool) *logger {
|
func newLogger(debug, info, err bool) *logger {
|
||||||
debugLog, infoLog, errLog := log.New(io.Discard, "➞ ", 0), log.New(io.Discard, "➞ ", 0), log.New(io.Discard, "➞ ", 0)
|
initPrefixBecauseWindowsSucksBallsHard()
|
||||||
|
|
||||||
|
debugLog, infoLog, errLog := log.New(io.Discard, prefix+" ", 0), log.New(io.Discard, prefix+" ", 0), log.New(io.Discard, prefix+" ", 0)
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
debugLog.SetOutput(os.Stdout)
|
debugLog.SetOutput(os.Stdout)
|
||||||
|
|
@ -118,11 +140,11 @@ func (l *logger) SetProgress(format string, v ...interface{}) {
|
||||||
select {
|
select {
|
||||||
case p := <-l.progress:
|
case p := <-l.progress:
|
||||||
if p.stop {
|
if p.stop {
|
||||||
fmt.Printf("\r" + strings.Repeat(" ", 2+len(initialMessage)))
|
fmt.Printf("\r" + strings.Repeat(" ", len(prefix)+len(initialMessage)))
|
||||||
if count > 1 {
|
if count > 1 {
|
||||||
fmt.Printf("\r↳ %s\n", p.message)
|
fmt.Printf("\r%s %s\n", progressDownFinish, p.message)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("\r➞ %s\n", p.message)
|
fmt.Printf("\r%s %s\n", prefix, p.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if l.done != nil {
|
if l.done != nil {
|
||||||
|
|
@ -134,7 +156,7 @@ func (l *logger) SetProgress(format string, v ...interface{}) {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
fmt.Printf("\r↓ %s\n", p.message)
|
fmt.Printf("\r%s %s\n", progressDown, p.message)
|
||||||
}
|
}
|
||||||
l.progress = make(chan progress, 1)
|
l.progress = make(chan progress, 1)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue