Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added --verbose option to show piece info bars #359

Merged
merged 1 commit into from Jun 16, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

added --verbose option to show piece info bars

closes #296
  • Loading branch information
janza committed Jun 14, 2015
commit ae5161aa42fc64c044193201fe70c8bdf4fe187b
@@ -54,7 +54,8 @@ var argv = minimist(process.argv.slice(2), {
'select',
'quiet',
'help',
'version'
'version',
'verbose'
],
default: {
port: 8000
@@ -142,6 +143,7 @@ function runHelp () {
-t, --subtitles [file] load subtitles file
-q, --quiet don't show UI on stdout
-v, --version print the current version
--verbose show piece progress bars
Please report bugs! https://github.com/feross/webtorrent/issues
@@ -519,21 +521,25 @@ function drawTorrent (torrent) {
clivas.line('{80:}')
linesRemaining -= 5

var pieces = torrent.storage.pieces
for (var i = 0; i < pieces.length; i++) {
var piece = pieces[i]
if (piece.verified || (piece.blocksWritten === 0 && !piece.blocks[0])) {
continue
}
var bar = ''
for (var j = 0; j < piece.blocks.length; j++) {
bar += piece.blocks[j] ? (piece.blocks[j] === 1 ? '{blue:█}' : '{green:█}') : '{red:█}'
if (argv.verbose) {

var pieces = torrent.storage.pieces
for (var i = 0; i < pieces.length; i++) {
var piece = pieces[i]
if (piece.verified || (piece.blocksWritten === 0 && !piece.blocks[0])) {
continue
}
var bar = ''
for (var j = 0; j < piece.blocks.length; j++) {
bar += piece.blocks[j] ? (piece.blocks[j] === 1 ? '{blue:█}' : '{green:█}') : '{red:█}'
}
clivas.line('{4+cyan:' + i + '} ' + bar)
linesRemaining -= 1
}
clivas.line('{4+cyan:' + i + '} ' + bar)
clivas.line('{80:}')
linesRemaining -= 1

}
clivas.line('{80:}')
linesRemaining -= 1

torrent.swarm.wires.every(function (wire) {
var progress = '?'
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.