@harborppm/cli 0.18.0 → 0.18.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.
- package/lib/cli.mjs +44 -6
- package/lib/format.mjs +1 -1
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -245,6 +245,11 @@ export function hint(message) {
|
|
|
245
245
|
"Say which with --harbor NAME, or set one with harbor use NAME.",
|
|
246
246
|
)
|
|
247
247
|
.replace(/Find it with search_tasks\.$/, "Find it with harbor tasks.")
|
|
248
|
+
.replace(
|
|
249
|
+
/^(.+) has no pre-mortem running\. Start one with start_premortem first\.$/s,
|
|
250
|
+
(_, name) =>
|
|
251
|
+
`${name} has no pre-mortem running. Start one with harbor premortem "${name}" --start.`,
|
|
252
|
+
)
|
|
248
253
|
.replace(
|
|
249
254
|
/^Nothing to change: pass a field to update\.$/,
|
|
250
255
|
"Nothing to change. Say what with --title, --assignee, --due, --priority, --status, --notes, --repeat or --waits-on.",
|
|
@@ -263,6 +268,36 @@ export function hint(message) {
|
|
|
263
268
|
);
|
|
264
269
|
}
|
|
265
270
|
|
|
271
|
+
/** get_premortem's answer with its note naming the command, not the agent tool, since --json shows it. */
|
|
272
|
+
export function premortemForTerminal(r) {
|
|
273
|
+
if (r.running || !r.note) return r;
|
|
274
|
+
return {
|
|
275
|
+
...r,
|
|
276
|
+
note: `No pre-mortem on ${r.project} yet. Start one with harbor premortem "${r.project}" --start.`,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Commands whose forms do different things: one line each, saying which read and which write. */
|
|
281
|
+
const DETAIL = {
|
|
282
|
+
premortem: [
|
|
283
|
+
" harbor premortem PROJECT reads it: the question, the time left,",
|
|
284
|
+
" and the answers you may see",
|
|
285
|
+
" harbor premortem PROJECT --start writes: starts one (five minutes of",
|
|
286
|
+
" answering alone, then they show)",
|
|
287
|
+
' harbor premortem PROJECT "ANSWER" writes: adds your answer',
|
|
288
|
+
' harbor premortem PROJECT "ANSWER" --start',
|
|
289
|
+
" writes: starts one and adds your answer",
|
|
290
|
+
"",
|
|
291
|
+
" PROJECT is a name or an id. When two projects share a name, give the id.",
|
|
292
|
+
],
|
|
293
|
+
voyage: [
|
|
294
|
+
" harbor voyage PROJECT reads a Done project's voyage log",
|
|
295
|
+
' harbor voyage PROJECT "YOUR LINE" writes: adds or changes your line in it',
|
|
296
|
+
"",
|
|
297
|
+
" PROJECT is a name or an id. When two projects share a name, give the id.",
|
|
298
|
+
],
|
|
299
|
+
};
|
|
300
|
+
|
|
266
301
|
/** The lines of the help about one command, or null when it has none. */
|
|
267
302
|
export function commandHelp(command) {
|
|
268
303
|
const lines = HELP.split("\n");
|
|
@@ -278,6 +313,7 @@ export function commandHelp(command) {
|
|
|
278
313
|
while (lines[i + 1]?.startsWith(" ") && /^\s+\[|^\s+--/.test(lines[i + 1]))
|
|
279
314
|
picked.push(lines[++i]);
|
|
280
315
|
}
|
|
316
|
+
if (DETAIL[command]) picked.splice(0, picked.length, ...DETAIL[command]);
|
|
281
317
|
if (picked.length === 0) return null;
|
|
282
318
|
const common = ["signup", "login", "logout", "use", "theme", "help", "app"].includes(command)
|
|
283
319
|
? []
|
|
@@ -591,11 +627,13 @@ export async function run(argv, io = {}) {
|
|
|
591
627
|
width: process.stdout.isTTY ? process.stdout.columns : undefined,
|
|
592
628
|
};
|
|
593
629
|
|
|
594
|
-
const call = async (name, args, show) => {
|
|
595
|
-
const result =
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
630
|
+
const call = async (name, args, show, forTerminal = (r) => r) => {
|
|
631
|
+
const result = forTerminal(
|
|
632
|
+
await client.call(name, args).catch((err) => {
|
|
633
|
+
if (err instanceof HarborError) throw new HarborError(hint(err.message));
|
|
634
|
+
throw err;
|
|
635
|
+
}),
|
|
636
|
+
);
|
|
599
637
|
// The prompt's counts are behind now; its next draw fetches new ones.
|
|
600
638
|
if (name === "create_task" || name === "update_task") await stalePromptCache(env);
|
|
601
639
|
out(asJson ? jsonText(result) : plain(show(result)));
|
|
@@ -1016,7 +1054,7 @@ export async function run(argv, io = {}) {
|
|
|
1016
1054
|
: `Added your answer (${r.answered.yourAnswers} so far).`,
|
|
1017
1055
|
);
|
|
1018
1056
|
}
|
|
1019
|
-
return call("get_premortem", { harbor, project }, premortemText);
|
|
1057
|
+
return call("get_premortem", { harbor, project }, premortemText, premortemForTerminal);
|
|
1020
1058
|
}
|
|
1021
1059
|
case "voyage": {
|
|
1022
1060
|
const { positionals, harbor } = parse(spec());
|
package/lib/format.mjs
CHANGED
|
@@ -214,7 +214,7 @@ export function premortemText(r) {
|
|
|
214
214
|
|
|
215
215
|
/** A project's voyage log, as get_voyage_log answers it. */
|
|
216
216
|
export function voyageText(r) {
|
|
217
|
-
const head = [`Voyage log · ${r.project}${r.done ? ` · Done ${r.finished}` : ""}`];
|
|
217
|
+
const head = [`Voyage log · ${r.project}${r.done ? ` · Done ${r.finished}` : " · not Done yet"}`];
|
|
218
218
|
if (r.note) head.push(r.note);
|
|
219
219
|
head.push((r.stats ?? []).join(" · "));
|
|
220
220
|
const story = (r.story ?? []).map((s) => ` - ${s}`);
|