@@ -16,10 +16,12 @@ const getAll = require('./utils/getAll.js');
1616const theEnd = require ( './utils/theEnd.js' ) ;
1717const handleError = require ( 'cli-handle-error' ) ;
1818const getCountry = require ( './utils/getCountry.js' ) ;
19+ const getStates = require ( './utils/getStates.js' ) ;
1920const getWorldwide = require ( './utils/getWorldwide.js' ) ;
20- const { single, colored, style } = require ( './utils/table.js' ) ;
21+ const { single, colored, singleStates , coloredStates , style } = require ( './utils/table.js' ) ;
2122const xcolor = cli . flags . xcolor ;
2223const sortBy = cli . flags . sort ;
24+ let isState = false ;
2325
2426( async ( ) => {
2527 // Init.
@@ -28,16 +30,28 @@ const sortBy = cli.flags.sort;
2830 if ( country === 'help' ) {
2931 cli . showHelp ( 0 ) ;
3032 }
33+ if ( country === 'states' ) {
34+ isState = true ;
35+ }
3136
3237 // Table
33- const head = xcolor ? single : colored ;
38+ let head ;
39+ if ( xcolor ) {
40+ head = isState ? singleStates : single ;
41+ } else {
42+ head = isState ? coloredStates : colored ;
43+ }
3444 const table = new Table ( { head, style } ) ;
3545
3646 // Display data.
3747 spinner . start ( ) ;
38- await getWorldwide ( table ) ;
39- await getCountry ( spinner , table , country ) ;
48+ if ( isState ) {
49+ await getStates ( spinner , table ) ;
50+ } else {
51+ await getWorldwide ( table ) ;
52+ await getCountry ( spinner , table , country ) ;
53+ }
4054 await getAll ( spinner , table , country , { sort : sortBy } ) ;
4155
42- theEnd ( ) ;
56+ theEnd ( isState ) ;
4357} ) ( ) ;
0 commit comments