mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
better ui
This commit is contained in:
parent
6ef44b8cb3
commit
0cfd3888b8
2 changed files with 10 additions and 1 deletions
|
@ -2,8 +2,10 @@ package receiver
|
|||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/mattn/go-colorable"
|
||||
|
@ -168,6 +170,8 @@ func (s *Session) receiveData(pathToFile string, fileSize int64) error {
|
|||
}()
|
||||
|
||||
firstByte := true
|
||||
_, fname := filepath.Split(pathToFile)
|
||||
fname = fmt.Sprintf("%10s", fname)
|
||||
var bar *progressbar.ProgressBar
|
||||
// Consume the message channel, until done
|
||||
// Does not stop on error
|
||||
|
@ -194,6 +198,8 @@ func (s *Session) receiveData(pathToFile string, fileSize int64) error {
|
|||
if firstByte {
|
||||
bar = progressbar.NewOptions64(
|
||||
fileSize,
|
||||
progressbar.OptionSetWidth(8),
|
||||
progressbar.OptionSetDescription(fname),
|
||||
progressbar.OptionSetRenderBlankState(true),
|
||||
progressbar.OptionSetBytes64(fileSize),
|
||||
progressbar.OptionSetWriter(os.Stderr),
|
||||
|
|
|
@ -2,6 +2,7 @@ package sender
|
|||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
|
@ -185,7 +186,7 @@ func (s *Session) readFile(pathToFile string) error {
|
|||
}
|
||||
stat, _ := f.Stat()
|
||||
s.fileSize = stat.Size()
|
||||
s.fname = stat.Name()
|
||||
s.fname = fmt.Sprintf("%12s", stat.Name())
|
||||
s.firstByte = true
|
||||
log.Debugf("Starting to read data from '%s'", pathToFile)
|
||||
s.readingStats.Start()
|
||||
|
@ -253,8 +254,10 @@ func (s *Session) onBufferedAmountLow() func() {
|
|||
s.sess.NetworkStats.AddBytes(uint64(cur.n))
|
||||
if s.firstByte {
|
||||
s.firstByte = false
|
||||
fmt.Fprint(os.Stderr, "\n")
|
||||
s.bar = progressbar.NewOptions64(
|
||||
s.fileSize,
|
||||
progressbar.OptionSetWidth(8),
|
||||
progressbar.OptionSetDescription(s.fname),
|
||||
progressbar.OptionSetRenderBlankState(true),
|
||||
progressbar.OptionSetBytes64(s.fileSize),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue