@enerlence/suntropy-cli 0.9.0 → 0.10.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.
- package/dist/bin/suntropy.js +46 -1
- package/dist/bin/suntropy.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/suntropy.js
CHANGED
|
@@ -398,6 +398,51 @@ function registerAuthCommands(program2) {
|
|
|
398
398
|
outputError(handleApiError(err));
|
|
399
399
|
}
|
|
400
400
|
});
|
|
401
|
+
auth.command("logout").description(
|
|
402
|
+
"Clear stored credentials for the active profile (or --profile). Removes the\ntoken and account identity but keeps the profile and its server URL.\nUse --all to log out of every profile."
|
|
403
|
+
).option("--all", "Clear credentials for ALL profiles").action(async (opts) => {
|
|
404
|
+
try {
|
|
405
|
+
const global = getGlobalOpts(auth);
|
|
406
|
+
const config = loadConfig();
|
|
407
|
+
const clearProfile = (name) => {
|
|
408
|
+
const profile = config.profiles[name];
|
|
409
|
+
if (!profile) return false;
|
|
410
|
+
const hadToken2 = !!profile.token;
|
|
411
|
+
delete profile.token;
|
|
412
|
+
delete profile.authMethod;
|
|
413
|
+
delete profile.email;
|
|
414
|
+
delete profile.clientUID;
|
|
415
|
+
delete profile.userUID;
|
|
416
|
+
return hadToken2;
|
|
417
|
+
};
|
|
418
|
+
if (opts.all) {
|
|
419
|
+
const names = Object.keys(config.profiles);
|
|
420
|
+
const clearedWithToken = names.filter(clearProfile);
|
|
421
|
+
saveConfig(config);
|
|
422
|
+
output({
|
|
423
|
+
success: true,
|
|
424
|
+
message: `Logged out of ${names.length} profile(s).`,
|
|
425
|
+
profiles: names,
|
|
426
|
+
hadCredentials: clearedWithToken
|
|
427
|
+
}, global);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
const profileName = global.profile || config.activeProfile;
|
|
431
|
+
if (!config.profiles[profileName]) {
|
|
432
|
+
outputError(new Error(`Profile "${profileName}" not found. Available: ${Object.keys(config.profiles).join(", ")}`));
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const hadToken = clearProfile(profileName);
|
|
436
|
+
saveConfig(config);
|
|
437
|
+
output({
|
|
438
|
+
success: true,
|
|
439
|
+
profile: profileName,
|
|
440
|
+
message: hadToken ? `Logged out of profile "${profileName}". Credentials cleared (server kept).` : `Profile "${profileName}" had no stored credentials.`
|
|
441
|
+
}, global);
|
|
442
|
+
} catch (err) {
|
|
443
|
+
outputError(err);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
401
446
|
}
|
|
402
447
|
|
|
403
448
|
// src/commands/config/shared.ts
|
|
@@ -4348,7 +4393,7 @@ function registerGeocodeCommands(program2) {
|
|
|
4348
4393
|
}
|
|
4349
4394
|
|
|
4350
4395
|
// src/index.ts
|
|
4351
|
-
var CLI_VERSION = true ? "0.
|
|
4396
|
+
var CLI_VERSION = true ? "0.10.0" : "0.0.0-dev";
|
|
4352
4397
|
function createProgram() {
|
|
4353
4398
|
const program2 = new Command3();
|
|
4354
4399
|
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)");
|