unjs / consola

๐Ÿจ Elegant Console Logger for Node.js and Browser
Other
5.78k stars 165 forks source link

feat: added progress bar utility #290

Open onmax opened 2 months ago

onmax commented 2 months ago

๐Ÿ”— Linked issue

N/A

โ“ Type of change

๐Ÿ“š Description

Added a new progress bar with a simple API:

https://github.com/unjs/consola/assets/22072217/dd9fa62d-01d8-449f-a2ef-8e4b722abbd6

I tried to make the API simple, but any feedback is welcome. Let me know if you would like to improve something!

const prog = progress({
    message: 'Your initial message' // Message next to the bar. Default to ''
    showPercentage: true, // Whether to show percentage after the bar or not. Default to false
    width: 50, // How many characters long. Default to 25
});

prog.update(0.5 /* value between 0 and 1*/, { message: 'Your new optional message' }) 

prog.stop() // Complete the bar and add new line

P.S. At the moment I am importing the function directly in the example because I am not completely sure how to

๐Ÿ“ Checklist