Last active
December 30, 2015 09:19
-
-
Save tmaeda1981jp/7808072 to your computer and use it in GitHub Desktop.
text progress bar example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.repeat = function(num) { | |
return new Array(num + 1).join(this); | |
}; | |
var sprintf = require('sprintf'), | |
util = require('util'), | |
colors = require('colors'), | |
total = 10000, | |
i; | |
console.log("This could take a while. You can run the following command on another shell to track the status:\n".green); | |
console.log(" tail -f ./path/to/output\n".yellow); | |
for (i=1; i<=total; i+=1) { | |
util.print('\r' + sprintf('[ %-100s ] %d / %d', '#'.repeat(Math.floor(i/total*100)), i, total)); | |
} | |
console.log("\n\nFinished!\n".green); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment