pixl-cli 1.0.19 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/cli.js +8 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -12,6 +12,7 @@
12
12
  + [TTY Detection](#tty-detection)
13
13
  + [Other Tools](#other-tools)
14
14
  * [Command-Line Arguments](#command-line-arguments)
15
+ + [Argument Aliases](#argument-aliases)
15
16
  + [Verbose Mode](#verbose-mode)
16
17
  + [Quiet Mode](#quiet-mode)
17
18
  * [Prompting The User](#prompting-the-user)
@@ -24,6 +25,7 @@
24
25
  + [Configuration](#configuration)
25
26
  + [Temporarily Erasing The Bar](#temporarily-erasing-the-bar)
26
27
  + [Customizing the Look](#customizing-the-look)
28
+ + [Indeterminite Progress](#indeterminite-progress)
27
29
  + [Changing Color Styles](#changing-color-styles)
28
30
  + [Automatic Width](#automatic-width)
29
31
  + [Keep progress bar visible](#keep-progress-bar-visible)
@@ -507,6 +509,7 @@ Calls to `cli.progress.start()` and `cli.progress.update()` accept an object con
507
509
  | `filling` | An array of characters to use as the bar chunk filling progression. |
508
510
  | `filled` | A single character representing one filled bar chunk, defaults to "⣿". |
509
511
  | `styles` | A set of color styles to use (see [Changing Color Styles](#changing-color-styles) below). |
512
+ | `pct` | Show percentage (defaults to `true`). |
510
513
 
511
514
  If you call `cli.progress.update()` and pass in a number, the library assumes you are just updating the `amount`. However, if you pass in an object, all the specified properties are updated.
512
515
 
@@ -554,6 +557,12 @@ cli.progress.start({
554
557
  });
555
558
  ```
556
559
 
560
+ ### Indeterminite Progress
561
+
562
+ For indeterminate progress, simply set the `amount` to the `max`. If these two values are identical, the progress bar is shown in an "indeterminate" state (e.g. the filled portion of the bar is drawn in a different color, default `gray`). This is to handle cases where a job "sits at 100%" but isn't quite complete, and also handle deliberate intermintate jobs (i.e. your code can just set the `amount` to the `max` to show an interminate bar). This also hides the time remaining.
563
+
564
+ For an additional UI hint, if you know your job is going to be indeterminate from the start, set the `pct` option to `false` to hide the percentage display. Otherwise it'll show "100%" during indeterminacy.
565
+
557
566
  ### Changing Color Styles
558
567
 
559
568
  The progress bar uses a set of color styles from the [chalk](https://www.npmjs.com/package/chalk) module or a custom function for the spinner, braces, bar chunks, percentage display, remaining time, and your custom text (if applicable). To customize these, pass in a `styles` object with the following keys:
@@ -564,6 +573,7 @@ cli.progress.start({
564
573
  spinner: ['bold', 'green'],
565
574
  braces: ['gray'],
566
575
  bar: ['bold', 'cyan'],
576
+ indeterminate: ['gray'],
567
577
  pct: ['bold', 'yellow'],
568
578
  remain: ['green'],
569
579
  text: [function( text ) { return text.toUpperCase() }]
@@ -573,6 +583,8 @@ cli.progress.start({
573
583
 
574
584
  Each key should be set to an array of styles supported by the [chalk](https://www.npmjs.com/package/chalk) module or a function. These are arrays because each component may contain multiple styles. For example, by default the `spinner`, `bar` and `pct` are styled with both a color and `bold`.
575
585
 
586
+ The `indeterminate` style is applied to the filled portion of the bar when the `amount` is exactly equal to the `max`.
587
+
576
588
  ### Automatic Width
577
589
 
578
590
  To set the progress bar size automatically to take up the full width of your Terminal window, you can use the `cli.width()` function. Just subtract 27 characters from it (possibly more if you use `indent` or `text`) to account for the spinner, braces, percentage and remaining time:
package/cli.js CHANGED
@@ -521,10 +521,12 @@ var cli = module.exports = {
521
521
  spinner: ['bold', 'green'],
522
522
  braces: ['gray'],
523
523
  bar: ['bold', 'cyan'],
524
+ indeterminate: ['gray'],
524
525
  pct: ['bold', 'yellow'],
525
526
  remain: ['green'],
526
527
  text: []
527
528
  },
529
+ pct: true,
528
530
  width: 30,
529
531
  freq: 100,
530
532
  remain: true,
@@ -627,13 +629,15 @@ var cli = module.exports = {
627
629
  }
628
630
  bar += cli.space(args.width - stringWidth(bar));
629
631
 
630
- line += cli.applyStyles( bar, args.styles.bar );
632
+ line += cli.applyStyles( bar, (args.amount === args.max) ? args.styles.indeterminate : args.styles.bar );
631
633
  line += cli.applyStyles( args.braces[1], args.styles.braces );
632
- line += " ";
633
634
 
634
635
  // percentage
635
- var pct = cli.pct(args.amount, args.max, true);
636
- line += cli.applyStyles( pct, args.styles.pct );
636
+ if (args.pct) {
637
+ line += " ";
638
+ var pct = cli.pct(args.amount, args.max, true);
639
+ line += cli.applyStyles( pct, args.styles.pct );
640
+ }
637
641
 
638
642
  // remaining
639
643
  var now = Tools.timeNow();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixl-cli",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Tools for building command-line apps for Node.js.",
5
5
  "author": "Joseph Huckaby <jhuckaby@gmail.com>",
6
6
  "homepage": "https://github.com/jhuckaby/pixl-cli",