1
1
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

better ui

This commit is contained in:
Zack Scholl 2019-04-11 11:04:59 -07:00
parent 197ca9a10d
commit 6ef44b8cb3
3 changed files with 7 additions and 4 deletions

View file

@ -35,7 +35,7 @@ func main() {
// PathToFile: "../wskeystore/README.md",
// PathToFile: "./src/croc/croc.go",
// PathToFiles: []string{"C:\\Users\\zacks\\go\\src\\github.com\\schollz\\croc\\src\\croc\\croc.go", "croc.exe"},
PathToFiles: []string{"croc2.exe"}, //,"croc2.exe", "croc3.exe"},
PathToFiles: []string{"croc2.exe", "croc3.exe"}, //,"croc2.exe", "croc3.exe"},
//PathToFiles: []string{"README.md"}, //,"croc2.exe", "croc3.exe"},
KeepPathInRemote: false,
})

View file

@ -36,7 +36,7 @@ var log = logrus.New()
func init() {
log.SetFormatter(&logrus.TextFormatter{ForceColors: true})
log.SetOutput(colorable.NewColorableStdout())
log.SetLevel(logrus.DebugLevel)
Debug(false)
}
func Debug(debug bool) {
@ -268,7 +268,7 @@ func (c *Client) transfer(options TransferOptions) (err error) {
if len(machID) > 6 {
machID = machID[:6]
}
fmt.Fprintf(os.Stderr, "Sending %s (%s) as '%s'\n", fname, utils.ByteCountDecimal(totalFilesSize), machID)
fmt.Fprintf(os.Stderr, "Sending %s (%s) from your machine, '%s'\n", fname, utils.ByteCountDecimal(totalFilesSize), machID)
}
// create channel for quitting
// quit with c.quit <- true

View file

@ -65,6 +65,7 @@ type Session struct {
readingStats *stats.Stats
bar *progressbar.ProgressBar
fileSize int64
fname string
firstByte bool
}
@ -184,6 +185,7 @@ func (s *Session) readFile(pathToFile string) error {
}
stat, _ := f.Stat()
s.fileSize = stat.Size()
s.fname = stat.Name()
s.firstByte = true
log.Debugf("Starting to read data from '%s'", pathToFile)
s.readingStats.Start()
@ -253,10 +255,11 @@ func (s *Session) onBufferedAmountLow() func() {
s.firstByte = false
s.bar = progressbar.NewOptions64(
s.fileSize,
progressbar.OptionSetDescription(s.fname),
progressbar.OptionSetRenderBlankState(true),
progressbar.OptionSetBytes64(s.fileSize),
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionThrottle(1/60*time.Second),
progressbar.OptionThrottle(100*time.Millisecond),
)
}
s.bar.Add(cur.n)