no bigspinner by default: use '-ww' for a spinner, '-www' bigger, '-wwww' max
This commit is contained in:
parent
289d9389a4
commit
818a6b0afe
@ -12,25 +12,40 @@
|
||||
*
|
||||
* Usage:
|
||||
* var distractions = require('./distractions');
|
||||
* var distraction = distractions.createDistraction();
|
||||
* var distraction = distractions.createDistraction([num]);
|
||||
* setTimeout(function () {
|
||||
* distraction.destroy();
|
||||
* }, 5000);
|
||||
*/
|
||||
|
||||
var assert = require('assert-plus');
|
||||
var bigspinner = require('bigspinner');
|
||||
|
||||
|
||||
function createDistraction() {
|
||||
function createDistraction(num) {
|
||||
assert.optionalNumber(num, 'num');
|
||||
|
||||
var height, width;
|
||||
if (num <= 2) {
|
||||
height = Math.min(5, process.stdout.rows - 2);
|
||||
width = Math.min(5*2, process.stdout.columns - 2);
|
||||
} else if (num === 3) {
|
||||
height = Math.min(10, process.stdout.rows - 2);
|
||||
width = Math.min(10*2, process.stdout.columns - 2);
|
||||
} else {
|
||||
var BORDER = 10;
|
||||
height = Math.max(2, process.stdout.rows - 2 - BORDER);
|
||||
width = Math.max(2, process.stdout.columns - 1 - BORDER);
|
||||
}
|
||||
return bigspinner.createSpinner({
|
||||
delay: 50,
|
||||
positions: 40,
|
||||
stream: process.stderr,
|
||||
height: Math.max(2, process.stdout.rows - 2 - BORDER),
|
||||
width: Math.max(2, process.stdout.columns - 1 - BORDER),
|
||||
height: height,
|
||||
width: width,
|
||||
hideCursor: true,
|
||||
fontChar: '\u2588' // '\x1b[7m \x1b[m'
|
||||
//fontChar: '\u2588' // '\x1b[7m \x1b[m'
|
||||
fontChar: '#'
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -125,9 +125,11 @@ function do_create_instance(subcmd, opts, args, callback) {
|
||||
return next();
|
||||
}
|
||||
|
||||
// 1 'wait': no distraction.
|
||||
// >1 'wait': distraction, pass in the N.
|
||||
var distraction;
|
||||
if (!opts.quiet && process.stderr.isTTY) {
|
||||
distraction = distractions.createDistraction();
|
||||
if (process.stderr.isTTY && opts.wait.length > 1) {
|
||||
distraction = distractions.createDistraction(opts.wait.length);
|
||||
}
|
||||
|
||||
// Dry-run: fake wait for a few seconds.
|
||||
@ -205,13 +207,9 @@ do_create_instance.options = [
|
||||
},
|
||||
{
|
||||
names: ['wait', 'w'],
|
||||
type: 'bool',
|
||||
help: 'Wait for the creation to complete.'
|
||||
},
|
||||
{
|
||||
names: ['quiet', 'q'],
|
||||
type: 'bool',
|
||||
help: 'No progress spinner while waiting.'
|
||||
type: 'arrayOfBool',
|
||||
help: 'Wait for the creation to complete. Use multiple times for a ' +
|
||||
'spinner.'
|
||||
},
|
||||
{
|
||||
names: ['json', 'j'],
|
||||
|
@ -72,8 +72,14 @@ function do_wait_instance(subcmd, opts, args, cb) {
|
||||
idsToWaitFor.length, states.join(', '));
|
||||
}
|
||||
|
||||
if (false && /* TODO: need BigSpinner.log first */
|
||||
!opts.quiet && process.stderr.isTTY)
|
||||
/*
|
||||
* TODO: need BigSpinner.log first.
|
||||
* TODO: Also when adding a spinner, we need an equiv option to
|
||||
* `triton create -wwww` to trigger the spinner (and size). By
|
||||
* default: no spinner.
|
||||
*/
|
||||
if (false &&
|
||||
process.stderr.isTTY)
|
||||
{
|
||||
distraction = distractions.createDistraction();
|
||||
}
|
||||
@ -122,11 +128,6 @@ do_wait_instance.options = [
|
||||
type: 'bool',
|
||||
help: 'Show this help.'
|
||||
},
|
||||
{
|
||||
names: ['quiet', 'q'],
|
||||
type: 'bool',
|
||||
help: 'No progress spinner while waiting.'
|
||||
},
|
||||
{
|
||||
names: ['states', 's'],
|
||||
type: 'arrayOfString',
|
||||
|
Reference in New Issue
Block a user