Moved the spinner initialization to the base class.

This commit is contained in:
David Diaz 2018-05-22 14:48:28 -06:00
parent dbc7addb39
commit d502f1dd01
2 changed files with 8 additions and 8 deletions

View File

@ -3,10 +3,16 @@ const fs = require('fs');
const path = require('path');
const dotenv = require('dotenv');
const { Command, flags } = require('@oclif/command');
const { Spinner } = require('clui');
const Beau = require('../../src/beau');
class Base extends Command {
async init() {
const spinnerSprite = ['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷'];
this.spinner = new Spinner('', spinnerSprite);
}
openConfigFile(configFile) {
if (!fs.existsSync(configFile)) {
this.error(`The config file, ${configFile} was not found.`);

View File

@ -1,6 +1,6 @@
const clc = require('cli-color');
const jsome = require('jsome');
const { Line, Spinner } = require('clui');
const { Line } = require('clui');
const { flags } = require('@oclif/command');
const Base = require('../base');
@ -47,12 +47,6 @@ class RequestCommand extends Base {
const Beau = this.loadConfig(config, params);
const spinnerSprite = ['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷'];
this.spinner = new Spinner(
clc.yellow(`Requesting: ${args.alias}`),
spinnerSprite
);
let spinnerEnabled = !noFormat && !asJson && !quiet;
if (spinnerEnabled) {
@ -78,7 +72,7 @@ class RequestCommand extends Base {
}
if (asJson) {
return this.log(JSON.stringify(res.response));
return this.log(JSON.stringify(verbose ? res : res.response));
}
if (noFormat) {