How to use cli-progress - 10 common examples

To help you get started, we’ve selected a few cli-progress examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libin1991 / webpack4-vue-react-more-page-cli / inquirer.js命令行交互的工具 / test2.js View on Github external
//进度条
//var Gauge = require("gauge")
//var gauge = new Gauge()
//var a = 0;
//var timer = setInterval(() => {
//	a += 0.01;
//	if(a > 1) {
//		clearInterval(timer)
//	}
//	gauge.show("test", a)
//}, 30)

const _cliProgress = require('cli-progress');
const terminal = require('terminal-utilities')
const bar1 = new _cliProgress.Bar({
	//	barCompleteChar: '#',
	//  barIncompleteChar: '.',
	//  fps: 5,
	//  stream: process.stdout,
	//  barsize: 65,
	//  position: 'center'
}, _cliProgress.Presets.shades_classic);
bar1.start(200, 0);
var a = 0
var timer = setInterval(() => {
	a = a + 10
	if(a > 200) {

		bar1.stop();
		//terminal.clear()   //清屏
		clearInterval(timer);
github torch2424 / live-stream-radio / src / stream / stream.js View on Github external
if (complexFilterString.length > 0) {
      complexFilterString += `, `;
    }
    complexFilterString += `${overlayTextFilterString}`;
  }

  // Set our final output video pad
  complexFilterString += ` [videooutput]`;

  // Apply our complext filter
  ffmpegCommand = ffmpegCommand.complexFilter(complexFilterString);

  // Let's create a nice progress bar
  // Using the song length as the 100%, as that is when the stream should end
  const songTotalDuration = Math.floor(metadata.format.duration);
  const progressBar = new progress.Bar(
    {
      format: 'Audio Progress {bar} {percentage}% | Time Playing: {duration_formatted} |'
    },
    progress.Presets.shades_classic
  );

  // Set our event handlers
  ffpmepgCommand = ffmpegCommand
    .on('start', commandString => {
      console.log(' ');
      console.log(`${chalk.blue('Spawned Ffmpeg with command:')}`);
      console.log(commandString);
      console.log(' ');

      // Start our progress bar
      progressBar.start(songTotalDuration, 0);
github carlosbaraza / unicorn-contributor / src / unicorn.js View on Github external
//  | |                        / ;   \;;,\
       (<_  | ;                      /',/-----'  _>
        \_| ||_                     //~;~~~~~~~~~
            `\_|                   (,~~
                                    \~\
                                     ~~

 */

import program from "commander";
import moment from "moment-timezone";
import { spawnSync } from "child_process";
import { times, randomInt, printUnicorn, processError } from "./utils";

const _progress = require('cli-progress');
const progressBar = new _progress.Bar({}, _progress.Presets.shades_classic);

export function deliverUnicorn() {
  sanityChecks();

  console.log('Generating your human looking contribution bar...\n');
  const days = initDaysList();
  assignContributionCommands(days);

  console.log('Running GIT contributions now...\n');
  progressBar.start(program.contributions, 0);
  contribute(days);
  celebrate();
}

function sanityChecks() {
  const gitLogResults = runCommand('git log').output;
github torch2424 / live-stream-radio / src / stream / stream.js View on Github external
}

  // Set our final output video pad
  complexFilterString += ` [videooutput]`;

  // Apply our complext filter
  ffmpegCommand = ffmpegCommand.complexFilter(complexFilterString);

  // Let's create a nice progress bar
  // Using the song length as the 100%, as that is when the stream should end
  const songTotalDuration = Math.floor(metadata.format.duration);
  const progressBar = new progress.Bar(
    {
      format: 'Audio Progress {bar} {percentage}% | Time Playing: {duration_formatted} |'
    },
    progress.Presets.shades_classic
  );

  // Set our event handlers
  ffpmepgCommand = ffmpegCommand
    .on('start', commandString => {
      console.log(' ');
      console.log(`${chalk.blue('Spawned Ffmpeg with command:')}`);
      console.log(commandString);
      console.log(' ');

      // Start our progress bar
      progressBar.start(songTotalDuration, 0);
    })
    .on('end', () => {
      progressBar.stop();
      if (endCallback) {
github nvuillam / sfdx-essentials / src / commands / essentials / change-dependency-version.ts View on Github external
// Get input arguments or default values
    this.namespace = flags.namespace;
    this.majorversion = flags.majorversion;
    this.minorversion = flags.minorversion;
    this.folder = flags.folder || '.';
    if (flags.verbose) {
      this.verbose = true;
    }
    console.log(`Initialize update of dependencies in ${this.folder} with ${this.namespace} ${this.majorversion}.${this.minorversion}`);

    // Read files
    const fileList = glob.sync('**/*.xml');

    // Progress bar
    // @ts-ignore
    this.progressBar = new cliProgress.SingleBar({
      format: '{name} [{bar}] {percentage}% | {value}/{total} | {file} ',
      stopOnComplete: true
    });
    if (this.progressBar.terminal.isTTY()) {
      this.progressBar.start(fileList.length, 0, { name: 'Progress', file: 'N/A' });
    }

    // Replace dependencies in files
    let updatedNb = 0;
    const parser = new xml2js.Parser();
    const promises = [];
    for (const sfdxXmlFile of fileList) {
      const filePromise = new Promise((resolve, reject) => {
        fs.readFile(sfdxXmlFile, (err, data) => {
          // Parse XML file
          parser.parseString(data, (err2, parsedXmlFile) => {
github nvuillam / sfdx-essentials / src / commands / essentials / uncomment.ts View on Github external
this.verbose = true;
    }

    console.log('Starting sfdx essentials:uncomment with uncomment key "' + this.uncommentKey + '"');

    // List apex classes
    const fetchClassesExpression = this.folder + '/classes/*.cls';
    const customApexClassFileNameList = glob.sync(fetchClassesExpression);

    // List aura items
    const fetchAuraExpression = this.folder + '/aura/**/*.js';
    const customAuraFileNameList = glob.sync(fetchAuraExpression);

    // Progress bar
    // @ts-ignore
    this.progressBar = new cliProgress.SingleBar({
      format: '{name} [{bar}] {percentage}% | {value}/{total} | {file} ',
      stopOnComplete: true
    });
    if (this.progressBar.terminal.isTTY()) {
      this.progressBar.start(customApexClassFileNameList.length + customAuraFileNameList.length, 0, { name: 'Progress', file: 'N/A' });
    }

    // Replace commented lines in each class
    customApexClassFileNameList.forEach((customApexClassFileName) => {
      this.processFile(customApexClassFileName);
      if (!this.verbose && this.progressBar.terminal.isTTY()) {
        this.progressBar.increment();
      }
    });

    // Replace commented lines in each aura item
github nvuillam / sfdx-essentials / src / commands / essentials / migrate-object-model.ts View on Github external
this.copySfdxProjectFolder = (flags.copySfdxProjectFolder === 'true');
    this.verbose = flags.verbose;

    if (flags.fetchExpressionList) {
      this.fetchExpressionList = flags.fetchExpressionList.split(',');
    } else if (flags.fetchExpressionList === '') {
      this.fetchExpressionList = [];
    }

    // Read config file and store it in class variable
    const jsonDataModelToMigrate = fs.readFileSync(this.configFile);
    this.configData = JSON.parse(jsonDataModelToMigrate.toString());

    // Build progress bars
    // @ts-ignore
    this.multibar = new cliProgress.MultiBar({
      clearOnComplete: false,
      hideCursor: true,
      fps: 500,
      format: '{name} [{bar}] {percentage}% | {value}/{total} | {file} '
    }, cliProgress.Presets.shades_grey);
    this.multibars.total = this.multibar.create(this.fetchExpressionList.length, 0, { name: 'Total'.padEnd(30, ' '), file: 'N/A' });
    // Expression list progress bars
    this.fetchExpressionList.forEach((fetchExpression: string) => {
      const customFileNameList = glob.sync(this.inputFolder + '/' + fetchExpression);
      if (this.multibar.terminal.isTTY()) {
        this.multibars[fetchExpression] = this.multibar.create(customFileNameList.length, 0, { name: fetchExpression.padEnd(30, ' '), file: 'N/A' });
      }
    });
    // Delete files progress bar
    if (this.deleteFiles && this.configData.objectToDelete && this.multibar.terminal.isTTY()) {
      this.multibars.deleteFiles = this.multibar.create(1, 0, { name: 'Delete files & folders'.padEnd(30, ' '), file: 'N/A' });
github ArkEcosystem / core / deprecated / core-snapshots-cli / src / commands / restore.ts View on Github external
public async run(): Promise {
        // tslint:disable-next-line:no-shadowed-variable
        const { flags } = this.parse(RestoreCommand);

        await setUpLite(flags);

        const emitter = app.resolvePlugin("event-emitter");

        const progressBar = new _cliProgress.Bar(
            {
                format: "{bar} {percentage}% | ETA: {eta}s | {value}/{total} | Duration: {duration}s",
            },
            _cliProgress.Presets.shades_classic,
        );

        emitter.on("start", data => {
            progressBar.start(data.count, 1);
        });

        emitter.on("progress", data => {
            progressBar.update(data.value);
        });

        emitter.on("complete", data => {
            progressBar.stop();
github apolloeleven / qa-screenshot-comparator / capture.js View on Github external
const captureScreenshots = async () => {

    // create a new progress bar instance and use shades_classic theme
    const bar1 = new _cliProgress.Bar({}, _cliProgress.Presets.shades_classic);

    let urls = await sitemapParser.getUrls(__dirname + '/sitemap.xml');
    const devicesToEmulate = [
        'iPhone 6',
        'iPhone 6 landscape',
        'iPhone 6 Plus',
        'Nexus 6',
        'iPad Pro'
    ];

    // urls = [
    //     'http://career.de.car1411dev.intermundia.de/',
    //     'http://career.de.car1411dev.intermundia.de/de/stellenangebote/leiter-projektmanagement-produktmanagement-m-w',
    //     'http://career.de.car1411dev.intermundia.de/de/was-wir-machen'
    // ];
    // urls = urls.slice(0, 10);
github AndiDittrich / NodeMCU-Tool / bin / nodemcu-tool.js View on Github external
.action(asyncWrapper(async (filelist, options) => {
        // initialize a new progress bar
        const bar = new _progressbar.Bar({
            clearOnComplete: true,
            hideCursor: true
        }, _progressbar.Presets.shades_classic);

        // expand glob expressions
        const files = await _globExpression.expand(filelist);

        // files provided ?
        if (files.length == 0){
            _logger.error('No files provided for upload (empty file-list)');
            return;
        }

        // handle multiple uploads
        let currentFileNumber = 0;

cli-progress

easy to use progress-bar for command-line/terminal applications

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis