@enerlence/suntropy-cli 0.5.1 → 0.6.0

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.
@@ -4206,8 +4206,75 @@ function registerShareableCommands(program2) {
4206
4206
  });
4207
4207
  }
4208
4208
 
4209
+ // src/commands/geocode/index.ts
4210
+ function getGlobalOpts14(cmd) {
4211
+ let root = cmd;
4212
+ while (root.parent) root = root.parent;
4213
+ return root.opts();
4214
+ }
4215
+ function emit(envelope, all, query, global) {
4216
+ if (envelope.error) {
4217
+ outputError({
4218
+ error: true,
4219
+ status: envelope.code,
4220
+ message: envelope.error.message || envelope.error.code || "Geocoding error",
4221
+ details: envelope.error
4222
+ });
4223
+ return;
4224
+ }
4225
+ const data = envelope.data;
4226
+ if (!data) {
4227
+ output({ found: false, ...query }, global);
4228
+ return;
4229
+ }
4230
+ if (all) {
4231
+ output(data.results, global);
4232
+ return;
4233
+ }
4234
+ if (data.count === 0) {
4235
+ output({ found: false, ...query }, global);
4236
+ return;
4237
+ }
4238
+ output(data.results[0], global);
4239
+ }
4240
+ function registerGeocodeCommands(program2) {
4241
+ const geocode = program2.command("geocode").description(
4242
+ "Geocoding via the solar service (proxy to Google Geocoding API).\nResolve an address into coordinates and vice versa."
4243
+ );
4244
+ geocode.command("resolve").description(
4245
+ 'Resolve an address into coordinates (lat/lng + formatted address).\nExamples:\n suntropy geocode resolve --address "Calle Mayor 1, Madrid"\n suntropy geocode resolve --address "Gran V\xEDa, Madrid" --country es --all'
4246
+ ).requiredOption("--address <string>", "Address to geocode (quote it)").option("--country <code>", "Bias results to a country (ISO code, e.g. es, pt, it)").option("--all", "Return all candidate matches instead of only the best one").action(async (opts) => {
4247
+ try {
4248
+ const global = getGlobalOpts14(geocode);
4249
+ const client = createServiceClient("solar", global);
4250
+ const res = await client.get(
4251
+ "/api/geocode",
4252
+ { params: { address: opts.address, country: opts.country } }
4253
+ );
4254
+ emit(res.data, opts.all, { address: opts.address }, global);
4255
+ } catch (err) {
4256
+ outputError(handleApiError(err));
4257
+ }
4258
+ });
4259
+ geocode.command("reverse").description(
4260
+ "Resolve coordinates into an address (reverse geocoding).\nExample:\n suntropy geocode reverse --lat 40.4168 --lng -3.7038"
4261
+ ).requiredOption("--lat <number>", "Latitude").requiredOption("--lng <number>", "Longitude").option("--all", "Return all candidate matches instead of only the best one").action(async (opts) => {
4262
+ try {
4263
+ const global = getGlobalOpts14(geocode);
4264
+ const client = createServiceClient("solar", global);
4265
+ const res = await client.get(
4266
+ "/api/reverse-geocode",
4267
+ { params: { lat: opts.lat, lng: opts.lng } }
4268
+ );
4269
+ emit(res.data, opts.all, { lat: opts.lat, lng: opts.lng }, global);
4270
+ } catch (err) {
4271
+ outputError(handleApiError(err));
4272
+ }
4273
+ });
4274
+ }
4275
+
4209
4276
  // src/index.ts
4210
- var CLI_VERSION = true ? "0.5.1" : "0.0.0-dev";
4277
+ var CLI_VERSION = true ? "0.6.0" : "0.0.0-dev";
4211
4278
  function createProgram() {
4212
4279
  const program2 = new Command2();
4213
4280
  program2.name("suntropy").description("Agent-first CLI for Suntropy solar platform. Optimized for programmatic data manipulation and progressive exploration.").version(CLI_VERSION).option("--format <format>", "Output format: json (default), human, csv", "json").option("--fields <fields>", "Comma-separated fields to include in output").option("--server <url>", "Override API server URL").option("--token <jwt>", "Override authentication token").option("--profile <name>", "Use a specific config profile").option("--verbose", "Show HTTP request/response details on stderr").option("--quiet", "Suppress non-data output").option("--save <file>", "Save output to file (also writes to stdout)");
@@ -4220,6 +4287,7 @@ function createProgram() {
4220
4287
  registerSolarformCommands(program2);
4221
4288
  registerPPACommands(program2);
4222
4289
  registerShareableCommands(program2);
4290
+ registerGeocodeCommands(program2);
4223
4291
  return program2;
4224
4292
  }
4225
4293