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

How to have several bar at the same time ? #26

Closed
Tchoupinax opened this issue Oct 5, 2018 · 4 comments
Closed

How to have several bar at the same time ? #26

Tchoupinax opened this issue Oct 5, 2018 · 4 comments

Comments

@Tchoupinax
Copy link

Hello,

I would like to have 2 cliProgress at the same time, one above the other. How can I make it ? With two instance, it appears that two are merged and one is seen when just updated.

Thank you. :)

@AndiDittrich
Copy link
Member

hi @Tchoupinax ,

this feature is currently not supported, sry!

best regards, Andi

@Tchoupinax
Copy link
Author

Ok,
Thank you for your answer. :)

@ryparker
Copy link

ryparker commented Aug 7, 2019

Hello,

I would like to have 2 cliProgress at the same time, one above the other. How can I make it ? With two instance, it appears that two are merged and one is seen when just updated.

Thank you. :)

If you're still looking for an option for multiple progress bars, I've been using https://github.com/pitaj/multi-progress without issue. It uses CLI-Progress bars.

@AndiDittrich
Copy link
Member

Multiprogress support has been added to v3.0.0

multibar

Example

const _progress = require('cli-progress');

const files = {
    'eta.js        ': 187,
    'generic-bar.js': 589,
    'multi-bar.js  ': 5342,
    'options.js    ': 42,
    'single-bar.js ': 2123,
    'terminal.js   ': 4123
};
const bars = [];

// create new container
const multibar = new _progress.MultiBar({
    format: ' {bar} | "{file}" | {value}/{total}',
    hideCursor: true,
    barCompleteChar: '\u2588',
    barIncompleteChar: '\u2591'

});

console.log("Downloading files..\n");

// add bars
for (const filename in files){
    const size = files[filename];

    bars.push(multibar.create(size, 0, {file: filename}));
}

const timer = setInterval(function(){

    // flag
    let downloadPending = false;

    // increment
    for (let i=0; i<bars.length;i++){
        const bar = bars[i];

        // download complete ?
        if (bar.value < bar.total){
            downloadPending = true;
            bar.increment();
        }
    }

    // stop progress bar ?
    if (downloadPending === false){
        clearInterval(timer);

        multibar.stop();
    }
}, 10);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants