@h-rig/task-cli-plugin 0.0.6-alpha.153 → 0.0.6-alpha.155

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/src/plugin.js +47 -7
  2. package/package.json +3 -3
@@ -5,6 +5,45 @@ var __require = import.meta.require;
5
5
  import { definePlugin } from "@rig/core/config";
6
6
  var STANDARD_TASK_CLI_PLUGIN_NAME = "@rig/task-cli-plugin";
7
7
  var STANDARD_TASK_CLI_ID = "@rig/task-cli-plugin:task";
8
+ function takeOption(args, flag) {
9
+ const rest = [...args];
10
+ const index = rest.indexOf(flag);
11
+ if (index < 0)
12
+ return { rest };
13
+ const value = rest[index + 1];
14
+ if (!value || value.startsWith("-"))
15
+ throw new Error(`${flag} requires a value.`);
16
+ rest.splice(index, 2);
17
+ return { value, rest };
18
+ }
19
+ function parsePositiveLimit(value) {
20
+ if (value === undefined)
21
+ return;
22
+ const parsed = Number.parseInt(value, 10);
23
+ if (!Number.isFinite(parsed) || parsed <= 0 || String(parsed) !== value.trim()) {
24
+ throw new Error("--limit must be a positive integer.");
25
+ }
26
+ return parsed;
27
+ }
28
+ function parseTaskFilters(args) {
29
+ const assignee = takeOption(args, "--assignee");
30
+ const state = takeOption(assignee.rest, "--state");
31
+ const limit = takeOption(state.rest, "--limit");
32
+ const search = takeOption(limit.rest, "--search");
33
+ const stateValue = state.value?.toLowerCase();
34
+ if (stateValue !== undefined && stateValue !== "open" && stateValue !== "closed") {
35
+ throw new Error(`Invalid --state value: ${state.value}`);
36
+ }
37
+ return {
38
+ filters: {
39
+ ...assignee.value ? { assignee: assignee.value } : {},
40
+ ...stateValue ? { state: stateValue } : {},
41
+ ...parsePositiveLimit(limit.value) !== undefined ? { limit: parsePositiveLimit(limit.value) } : {},
42
+ ...search.value?.trim() ? { search: search.value.trim() } : {}
43
+ },
44
+ rest: search.rest
45
+ };
46
+ }
8
47
  function taskListTitle(task) {
9
48
  const title = typeof task.title === "string" && task.title.trim().length > 0 ? task.title.trim() : "(untitled)";
10
49
  const status = typeof task.status === "string" && task.status.trim().length > 0 ? ` [${task.status.trim()}]` : "";
@@ -16,23 +55,24 @@ function createStandardTaskCliCommand() {
16
55
  id: STANDARD_TASK_CLI_ID,
17
56
  family: "task",
18
57
  description: "List and inspect task-source tasks.",
19
- usage: "rig task list",
58
+ usage: "rig task list [--assignee <login|me|@me>] [--state open|closed] [--search <text>] [--limit <n>]",
20
59
  projectRequired: true,
21
60
  run: async (context, args) => {
22
61
  const [command = "help", ...rest] = [...args];
23
62
  if (command === "help" || command === "--help" || command === "-h") {
24
63
  if (context.outputMode === "text")
25
- console.log("Usage: rig task list");
64
+ console.log("Usage: rig task list [--assignee <login|me|@me>] [--state open|closed] [--search <text>] [--limit <n>]");
26
65
  return { ok: true, group: "task", command: "help" };
27
66
  }
28
67
  if (command !== "list") {
29
68
  throw new Error(`Unsupported standard task command: ${command}. Use 'rig task list'.`);
30
69
  }
31
- if (rest.length > 0) {
32
- throw new Error(`Unsupported arguments for rig task list: ${rest.join(" ")}`);
70
+ const parsed = parseTaskFilters(rest);
71
+ if (parsed.rest.length > 0) {
72
+ throw new Error(`Unsupported arguments for rig task list: ${parsed.rest.join(" ")}`);
33
73
  }
34
- const { listTasks } = await import("@rig/client");
35
- const tasks = await listTasks(context.projectRoot);
74
+ const { applyFilters, listTasks } = await import("@rig/client");
75
+ const tasks = applyFilters(await listTasks(context.projectRoot), parsed.filters);
36
76
  if (context.outputMode === "text") {
37
77
  if (tasks.length === 0) {
38
78
  console.log("No tasks found.");
@@ -55,7 +95,7 @@ function createStandardTaskCliPlugin() {
55
95
  id: STANDARD_TASK_CLI_ID,
56
96
  family: "task",
57
97
  description: "List and inspect task-source tasks.",
58
- usage: "rig task list",
98
+ usage: "rig task list [--assignee <login|me|@me>] [--state open|closed] [--search <text>] [--limit <n>]",
59
99
  projectRequired: true
60
100
  }
61
101
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/task-cli-plugin",
3
- "version": "0.0.6-alpha.153",
3
+ "version": "0.0.6-alpha.155",
4
4
  "type": "module",
5
5
  "description": "Standard Rig task CLI plugin boundary backed by the Rig client runtime.",
6
6
  "license": "UNLICENSED",
@@ -22,7 +22,7 @@
22
22
  "bun": ">=1.3.11"
23
23
  },
24
24
  "dependencies": {
25
- "@rig/client": "npm:@h-rig/client@0.0.6-alpha.153",
26
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.153"
25
+ "@rig/client": "npm:@h-rig/client@0.0.6-alpha.155",
26
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.155"
27
27
  }
28
28
  }