pdlab-cli 0.2.0 → 0.2.1

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 (2) hide show
  1. package/dist/index.js +11 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  // src/index.ts
27
27
  var import_fs2 = require("fs");
28
28
  var import_path2 = require("path");
29
- var import_commander = require("commander");
29
+ var import_commander2 = require("commander");
30
30
 
31
31
  // src/commands/login.ts
32
32
  var import_open = __toESM(require("open"));
@@ -339,6 +339,7 @@ var postReviewSchema = import_zod3.z.object({
339
339
  });
340
340
 
341
341
  // src/errors.ts
342
+ var import_commander = require("commander");
342
343
  var import_zod4 = require("zod");
343
344
  var EXIT_CODES = {
344
345
  ok: 0,
@@ -390,6 +391,8 @@ function handleCommandError(error, examples = []) {
390
391
  };
391
392
  } else if (error instanceof CliError) {
392
393
  structured = { error: error.message, code: error.code, status: null, hint: "pdlab login" };
394
+ } else if (error instanceof import_commander.CommanderError) {
395
+ structured = { error: error.message.replace(/^error:\s*/, ""), code: "validation", status: null, hint: exampleHint(examples) };
393
396
  } else {
394
397
  structured = {
395
398
  error: error instanceof Error ? error.message : String(error),
@@ -794,8 +797,11 @@ function registerSchemaCommand(program2) {
794
797
 
795
798
  // src/index.ts
796
799
  var pkg = JSON.parse((0, import_fs2.readFileSync)((0, import_path2.join)(__dirname, "../package.json"), "utf8"));
797
- var program = new import_commander.Command();
800
+ var program = new import_commander2.Command();
798
801
  program.name("pdlab").description("1836 \u5F00\u6E90\u5171\u5EFA\u5E73\u53F0\u547D\u4EE4\u884C\u5DE5\u5177\u2014\u2014\u662F\u73B0\u6709 REST API \u7684\u8584\u5C01\u88C5\u3002\u7ED9 agent/\u811A\u672C\u7528\uFF1Apdlab schema \u4E00\u6B21\u6027\u5217\u51FA\u5168\u90E8\u547D\u4EE4\u3001\u53C2\u6570\u4E0E\u9000\u51FA\u7801\u542B\u4E49\u3002").version(pkg.version);
802
+ program.exitOverride();
803
+ program.configureOutput({ writeErr: () => {
804
+ } });
799
805
  registerLoginCommand(program);
800
806
  registerRegisterCommand(program);
801
807
  registerLogoutCommand(program);
@@ -805,5 +811,8 @@ registerProjectCommand(program);
805
811
  registerPostCommand(program);
806
812
  registerSchemaCommand(program);
807
813
  program.parseAsync(process.argv).catch((error) => {
814
+ if (error instanceof import_commander2.CommanderError && error.exitCode === 0) {
815
+ process.exit(0);
816
+ }
808
817
  handleCommandError(error);
809
818
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdlab-cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "private": false,
5
5
  "description": "1836 开源共建平台(problem-driven-lab)的命令行工具:项目、内容的增删改查,浏览器授权登录",
6
6
  "keywords": [