@hcmai/cli 0.21.2 → 0.21.4

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/index.js CHANGED
@@ -3993,7 +3993,7 @@ async function queryCommand(model, args) {
3993
3993
  const client3 = HcmClient2.fromAuthContext(await getActiveAuthContextFromCli(args));
3994
3994
  const result = await client3.query(model, dsl);
3995
3995
  const fmt = args.output ?? "table";
3996
- printQueryResult(result, fmt);
3996
+ printQueryResult(result, fmt, dsl);
3997
3997
  } catch (e) {
3998
3998
  const err = e;
3999
3999
  if (err?.isAxiosError) {
@@ -4015,13 +4015,31 @@ function buildQueryDsl(args) {
4015
4015
  if (!dsl.limit) dsl.limit = 20;
4016
4016
  return dsl;
4017
4017
  }
4018
- function printQueryResult(result, fmt) {
4018
+ function printQueryResult(result, fmt, dsl = {}) {
4019
4019
  const out = formatRows(result.rows, { format: fmt });
4020
4020
  process.stdout.write(out + "\n");
4021
4021
  if (fmt === "table" && result.total !== void 0) {
4022
4022
  process.stdout.write(`Showing ${result.rows.length} of ${result.total} results.
4023
4023
  `);
4024
4024
  }
4025
+ const limit = dsl.limit ?? 20;
4026
+ const offset = Math.floor((dsl.offset ?? 0) / limit) * limit;
4027
+ const nextPage = `\u8BF7\u6309 --limit ${limit} --offset ${offset + limit} \u7EE7\u7EED\u67E5\u8BE2\uFF1B\u5168\u91CF\u7EDF\u8BA1\u5FC5\u987B\u6536\u9F50\u6240\u6709\u5206\u9875\u3002`;
4028
+ if (typeof result.total === "number" && Number.isSafeInteger(result.total) && result.total >= 0) {
4029
+ if (result.total > result.rows.length) {
4030
+ const nextStep = result.total > offset + result.rows.length ? nextPage : "\u5DF2\u5230\u672B\u9875\uFF1B\u5168\u91CF\u7EDF\u8BA1\u8BF7\u4ECE --offset 0 \u5F00\u59CB\u6536\u9F50\u6240\u6709\u5206\u9875\u3002";
4031
+ process.stderr.write(
4032
+ `\u67E5\u8BE2\u7ED3\u679C\u672A\u53D6\u5168\uFF1A\u672C\u9875\u8FD4\u56DE ${result.rows.length} \u6761\uFF0C\u5339\u914D\u603B\u6570 ${result.total}\uFF0Climit=${limit}\uFF0Coffset=${offset}\u3002${nextStep}
4033
+ `
4034
+ );
4035
+ }
4036
+ } else if (result.rows.length >= limit || offset > 0) {
4037
+ const nextStep = result.rows.length >= limit ? nextPage : "\u672C\u6B21\u672A\u67E5\u8BE2\u6B64\u524D\u5206\u9875\uFF1B\u8BF7\u4ECE --offset 0 \u5F00\u59CB\u6536\u9F50\u6240\u6709\u5206\u9875\u3002";
4038
+ process.stderr.write(
4039
+ `\u5339\u914D\u603B\u6570\u672A\u77E5\uFF1A\u672C\u9875\u8FD4\u56DE ${result.rows.length} \u6761\uFF0Coffset=${offset}\uFF0C\u7ED3\u679C\u53EF\u80FD\u4E0D\u5B8C\u6574\uFF08limit=${limit}\uFF09\u3002${nextStep}
4040
+ `
4041
+ );
4042
+ }
4025
4043
  process.exitCode = 0;
4026
4044
  }
4027
4045
  function parseAdditionsOrThrow(text) {