File tree Expand file tree Collapse file tree 6 files changed +368
-0
lines changed
Expand file tree Collapse file tree 6 files changed +368
-0
lines changed Original file line number Diff line number Diff line change 1+ node_modules /
2+ .DS_Store
3+ npm-debug.log
Original file line number Diff line number Diff line change 1+ # fancy-progress-cli
2+
3+ A stylish, emoji-themed CLI progress bar.
4+
5+ ## Install
6+
7+ ``` bash
8+ npm install -g fancy-progress-cli
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ const cliProgress = require ( "cli-progress" ) ;
4+ const chalk = require ( "chalk" ) ;
5+ const yargs = require ( "yargs" ) ;
6+ const themes = require ( "./themes" ) ;
7+
8+ const argv = yargs
9+ . option ( "total" , {
10+ alias : "t" ,
11+ type : "number" ,
12+ default : 50 ,
13+ describe : "Total number of steps" ,
14+ } )
15+ . option ( "speed" , {
16+ alias : "s" ,
17+ type : "number" ,
18+ default : 100 ,
19+ describe : "Interval speed in ms" ,
20+ } )
21+ . option ( "theme" , {
22+ alias : "m" ,
23+ choices : Object . keys ( themes ) ,
24+ default : "classic" ,
25+ describe : "Progress bar theme" ,
26+ } )
27+ . option ( "message" , {
28+ alias : "msg" ,
29+ type : "string" ,
30+ describe : "Completion message" ,
31+ } )
32+ . help ( ) . argv ;
33+
34+ const theme = themes [ argv . theme ] ;
35+
36+ const bar = new cliProgress . SingleBar ( {
37+ format : `{bar} | ${ chalk . cyan ( "{percentage}%" ) } | ${ chalk . green ( "{value}/{total}" ) } ` ,
38+ barCompleteChar : theme . complete ,
39+ barIncompleteChar : theme . incomplete ,
40+ hideCursor : true ,
41+ } ) ;
42+
43+ const total = argv . total ;
44+ bar . start ( total , 0 ) ;
45+
46+ let value = 0 ;
47+ const interval = setInterval ( ( ) => {
48+ value ++ ;
49+ bar . update ( value ) ;
50+ if ( value >= total ) {
51+ bar . stop ( ) ;
52+ clearInterval ( interval ) ;
53+ if ( argv . message ) {
54+ console . log ( chalk . green ( `🎉 ${ argv . message } ` ) ) ;
55+ } else {
56+ console . log ( chalk . cyan ( "✅ All done!" ) ) ;
57+ }
58+ }
59+ } , argv . speed ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " fancy-progress-cli" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " A customizable emoji-themed CLI progress bar tool" ,
5+ "main" : " cli.js" ,
6+ "bin" : {
7+ "fancy-progress" : " ./cli.js"
8+ },
9+ "scripts" : {
10+ "start" : " node cli.js"
11+ },
12+ "keywords" : [
13+ " cli" ,
14+ " progress-bar" ,
15+ " emoji" ,
16+ " terminal" ,
17+ " console" ,
18+ " fancy" ,
19+ " nodejs"
20+ ],
21+ "author" :
" Sameer Shaikh <[email protected] >" ,
22+ "license" : " MIT" ,
23+ "dependencies" : {
24+ "chalk" : " ^4.1.2" ,
25+ "cli-progress" : " ^3.9.1" ,
26+ "yargs" : " ^17.7.2"
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ module . exports = {
2+ classic : {
3+ complete : '█' ,
4+ incomplete : '░'
5+ } ,
6+ stars : {
7+ complete : '★' ,
8+ incomplete : '☆'
9+ } ,
10+ hearts : {
11+ complete : '❤' ,
12+ incomplete : '♡'
13+ } ,
14+ dots : {
15+ complete : '●' ,
16+ incomplete : '○'
17+ } ,
18+ blocks : {
19+ complete : '▓' ,
20+ incomplete : '▒'
21+ }
22+ } ;
23+
You can’t perform that action at this time.
0 commit comments