@countrystatecity/cli 0.1.4 → 0.1.5
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.
- package/README.md +3 -0
- package/dist/index.js +12 -15
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -449,28 +449,25 @@ function registerSearchCommands(program2) {
|
|
|
449
449
|
}
|
|
450
450
|
printUsageFooter(usage, flags);
|
|
451
451
|
});
|
|
452
|
-
search3.command("states").description("List states for a country").option("-c, --country <iso2>", "Country ISO2 code").option("--filter <text>", "Filter by name").action(async (options, cmd) => {
|
|
452
|
+
search3.command("states").description("List states for a country, or all states globally").option("-c, --country <iso2>", "Country ISO2 code (omit to get all states globally)").option("--filter <text>", "Filter by name").action(async (options, cmd) => {
|
|
453
453
|
const globalOpts = cmd.optsWithGlobals();
|
|
454
454
|
const flags = {
|
|
455
455
|
json: globalOpts.json ?? false,
|
|
456
456
|
quiet: globalOpts.quiet ?? false,
|
|
457
457
|
noFooter: globalOpts.footer === false
|
|
458
458
|
};
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
process.exit(1);
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
459
|
+
const code = options.country?.toUpperCase();
|
|
460
|
+
let endpoint;
|
|
461
|
+
let spinnerText;
|
|
462
|
+
if (code) {
|
|
463
|
+
endpoint = `/countries/${code}/states`;
|
|
464
|
+
spinnerText = `Fetching states for ${code}...`;
|
|
465
|
+
} else {
|
|
466
|
+
endpoint = "/states";
|
|
467
|
+
spinnerText = "Fetching all states...";
|
|
471
468
|
}
|
|
472
|
-
const spinner = await createSpinner(
|
|
473
|
-
const { data, usage } = await get(
|
|
469
|
+
const spinner = await createSpinner(spinnerText, flags);
|
|
470
|
+
const { data, usage } = await get(endpoint);
|
|
474
471
|
spinner.stop();
|
|
475
472
|
let states = data;
|
|
476
473
|
if (options.filter) {
|