File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed
Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -80,14 +80,27 @@ const { argv } = yargs
8080 . help ( 'help' ) ;
8181
8282argv . countryCode = argv . country ;
83- if ( argv . states === 'US' ) {
84- getUsaStats ( argv ) . then ( result => {
85- console . log ( result ) ;
86- process . exit ( 1 ) ;
87- } ) . catch ( error => {
88- console . error ( error ) ;
89- process . exit ( 0 ) ;
90- } ) ;
83+ if ( argv . states ) {
84+ const country = lookupCountry ( argv . states ) ;
85+ if ( ! country ) {
86+ let error = `Country '${ argv . states } ' not found.\n` ;
87+ error += 'Try full country name or country code.\n' ;
88+ error += 'Ex:\n' ;
89+ error += '- UK: for United Kingdom \n' ;
90+ error += '- US: for United States of America.\n' ;
91+ error += '- Italy: for Italy.\n' ;
92+ throw new Error ( chalk . red . bold ( error ) ) ;
93+ }
94+ argv . countryCode = country . iso2 ;
95+ if ( argv . countryCode === 'US' ) {
96+ getUsaStats ( argv ) . then ( result => {
97+ console . log ( result ) ;
98+ process . exit ( 1 ) ;
99+ } ) . catch ( error => {
100+ console . error ( error ) ;
101+ process . exit ( 0 ) ;
102+ } ) ;
103+ }
91104}
92105
93106if ( argv . source === 1 ) {
@@ -98,7 +111,7 @@ if (argv.source === 1) {
98111 ) . then ( console . log ) . catch ( console . error ) ;
99112}
100113else if ( argv . graph === true ) {
101- getGraph ( argv . countryCode ) . then ( console . log ) . catch ( console . error ) ;
114+ getGraph ( argv ) . then ( console . log ) . catch ( console . error ) ;
102115} else {
103116 getWorldoMetersTable ( argv ) . then ( console . log ) . catch ( console . error ) ;
104117}
You can’t perform that action at this time.
0 commit comments