@countrystatecity/cli 0.1.6 → 0.1.7

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 +1 -21
  2. package/dist/index.js +9 -100
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -62,9 +62,6 @@ csc search states
62
62
  csc search states --country IN
63
63
  csc search states -c US --filter "new"
64
64
 
65
- # List all cities globally
66
- csc search cities
67
-
68
65
  # List all cities for a country
69
66
  csc search cities --country IN
70
67
 
@@ -72,23 +69,10 @@ csc search cities --country IN
72
69
  csc search cities --country IN --state MH
73
70
  csc search cities -c US -s CA --json
74
71
 
75
- # List all world regions
72
+ # List all world regions (requires Starter plan+)
76
73
  csc search regions
77
74
  csc search regions --filter "asia"
78
75
 
79
- # List all currencies
80
- csc search currencies
81
- csc search currencies --filter "dollar"
82
-
83
- # List all timezones
84
- csc search timezones
85
- csc search timezones --country IN
86
- csc search timezones --filter "kolkata"
87
-
88
- # List all country phone codes
89
- csc search phonecodes
90
- csc search phonecodes --filter "india"
91
-
92
76
  # Global search (matches country names)
93
77
  csc search india
94
78
  ```
@@ -105,10 +89,6 @@ csc get country # Interactive — prompts to pick a country (TTY only)
105
89
  csc get state IN MH
106
90
  csc get state IN MH --json
107
91
  csc get state # Interactive — prompts for country then state (TTY only)
108
-
109
- # Detailed city info by ID
110
- csc get city IN MH 57589
111
- csc get city IN MH 57589 --json
112
92
  ```
113
93
 
114
94
  ### Usage & Billing
package/dist/index.js CHANGED
@@ -74,6 +74,11 @@ async function get(path) {
74
74
  console.error(chalk.dim("Run `csc auth login` to set your key."));
75
75
  process.exit(1);
76
76
  }
77
+ if (status === 403) {
78
+ console.error(chalk.red("Access denied \u2014 this endpoint requires a higher plan."));
79
+ console.error(chalk.dim("Run `csc upgrade` to view available plans."));
80
+ process.exit(1);
81
+ }
77
82
  if (status === 429) {
78
83
  console.error(chalk.red("Daily limit reached."));
79
84
  console.error(chalk.yellow("Run `csc upgrade` to increase your limits."));
@@ -487,8 +492,10 @@ function registerSearchCommands(program2) {
487
492
  endpoint = `/countries/${countryCode}/cities`;
488
493
  spinnerText = `Fetching all cities for ${countryCode}...`;
489
494
  } else {
490
- endpoint = "/cities";
491
- spinnerText = "Fetching all cities...";
495
+ process.stderr.write(chalk5.red("Country code required. Use --country IN\n"));
496
+ process.stderr.write(chalk5.dim("Use --state MH to filter by state.\n"));
497
+ process.exit(1);
498
+ return;
492
499
  }
493
500
  const spinner = await createSpinner(spinnerText, flags);
494
501
  const { data, usage } = await get(endpoint);
@@ -528,76 +535,6 @@ function registerSearchCommands(program2) {
528
535
  }
529
536
  printUsageFooter(usage, flags);
530
537
  });
531
- search3.command("currencies").description("List all currencies").option("--filter <text>", "Filter by name or code").action(async (options, cmd) => {
532
- const flags = resolveFlags(cmd);
533
- const spinner = await createSpinner("Fetching currencies...", flags);
534
- const { data, usage } = await get("/currencies");
535
- spinner.stop();
536
- let currencies = data;
537
- if (options.filter) {
538
- const term = options.filter.toLowerCase();
539
- currencies = currencies.filter(
540
- (c) => c.name.toLowerCase().includes(term) || (c.code || "").toLowerCase().includes(term)
541
- );
542
- }
543
- if (flags.json) {
544
- printJson(currencies);
545
- } else {
546
- printTable(
547
- ["ID", "Name", "Symbol", "Code"],
548
- currencies.map((c) => [String(c.id), c.name, c.symbol || "", c.code || ""])
549
- );
550
- }
551
- printUsageFooter(usage, flags);
552
- });
553
- search3.command("timezones").description("List all timezones").option("-c, --country <iso2>", "Filter by country ISO2 code").option("--filter <text>", "Filter by zone name or abbreviation").action(async (options, cmd) => {
554
- const flags = resolveFlags(cmd);
555
- const spinner = await createSpinner("Fetching timezones...", flags);
556
- const { data, usage } = await get("/timezones");
557
- spinner.stop();
558
- let timezones = data;
559
- if (options.country) {
560
- const code = options.country.toUpperCase();
561
- timezones = timezones.filter((t) => (t.countryCode || "").toUpperCase() === code);
562
- }
563
- if (options.filter) {
564
- const term = options.filter.toLowerCase();
565
- timezones = timezones.filter(
566
- (t) => t.zoneName.toLowerCase().includes(term) || t.abbreviation.toLowerCase().includes(term)
567
- );
568
- }
569
- if (flags.json) {
570
- printJson(timezones);
571
- } else {
572
- printTable(
573
- ["Zone Name", "Abbreviation", "UTC Offset", "TZ Name"],
574
- timezones.map((t) => [t.zoneName, t.abbreviation, t.gmtOffsetName || String(t.gmtOffset), t.tzName || ""])
575
- );
576
- }
577
- printUsageFooter(usage, flags);
578
- });
579
- search3.command("phonecodes").description("List all country phone codes").option("--filter <text>", "Filter by country name or code").action(async (options, cmd) => {
580
- const flags = resolveFlags(cmd);
581
- const spinner = await createSpinner("Fetching phone codes...", flags);
582
- const { data, usage } = await get("/phone-codes");
583
- spinner.stop();
584
- let phonecodes = data;
585
- if (options.filter) {
586
- const term = options.filter.toLowerCase();
587
- phonecodes = phonecodes.filter(
588
- (p) => p.name.toLowerCase().includes(term) || (p.iso2 || "").toLowerCase().includes(term)
589
- );
590
- }
591
- if (flags.json) {
592
- printJson(phonecodes);
593
- } else {
594
- printTable(
595
- ["ISO2", "Name", "Phone Code"],
596
- phonecodes.map((p) => [p.iso2 || "", p.name, `+${p.phonecode.replace(/^\+/, "")}`])
597
- );
598
- }
599
- printUsageFooter(usage, flags);
600
- });
601
538
  search3.argument("[query]", "Search term to match country names").action(async (query, options, cmd) => {
602
539
  if (!query) return;
603
540
  const flags = resolveFlags(cmd);
@@ -749,34 +686,6 @@ function registerGetCommands(program2) {
749
686
  }
750
687
  printUsageFooter(usage, flags);
751
688
  });
752
- getCmd.command("city <country_iso2> <state_iso2> <city_id>").description("Get detailed city information by ID").action(async (countryIso2, stateIso2, cityId, options, cmd) => {
753
- const globalOpts = cmd.optsWithGlobals();
754
- const flags = {
755
- json: globalOpts.json ?? false,
756
- quiet: globalOpts.quiet ?? false,
757
- noFooter: globalOpts.footer === false
758
- };
759
- const countryCode = countryIso2.toUpperCase();
760
- const stateCode = stateIso2.toUpperCase();
761
- const spinner = await createSpinner(`Fetching city ${cityId}...`, flags);
762
- const { data, usage } = await get(
763
- `/countries/${countryCode}/states/${stateCode}/cities/${cityId}`
764
- );
765
- spinner.stop();
766
- if (flags.json) {
767
- printJson(data);
768
- } else {
769
- const city = data;
770
- printDetail("City:", city.name);
771
- printDetail("ID:", String(city.id));
772
- printDetail("State:", city.state_code || stateCode);
773
- printDetail("Country:", city.country_code || countryCode);
774
- if (city.latitude && city.longitude) {
775
- printDetail("Coordinates:", `${formatCoord(city.latitude)}, ${formatCoord(city.longitude)}`);
776
- }
777
- }
778
- printUsageFooter(usage, flags);
779
- });
780
689
  }
781
690
 
782
691
  // src/commands/usage.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@countrystatecity/cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Official CLI for the Country State City API - search, explore, and generate code from geographic data",
5
5
  "files": [
6
6
  "dist",