@kaynooo/cli-pick 0.1.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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/pick.js +118 -56
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @kaynooo/cli-pick
2
2
 
3
- `pick` is a fuzzy selector in the colours of the other @kaynooo CLIs: lines on stdin, the chosen one on stdout.
3
+ `pick` is a fuzzy selector in the colours of the other @kaynooo CLIs: lines on stdin, the chosen one on stdout. It is for a person at a terminal, not for a Claude Code session, which has no terminal to answer it.
4
4
 
5
5
  ```sh
6
6
  bun add -g @kaynooo/cli-pick
package/dist/pick.js CHANGED
@@ -1,15 +1,14 @@
1
- #!/usr/bin/env bun
1
+ #!/usr/bin/env -S bun --no-env-file
2
2
  // @bun
3
3
 
4
4
  // src/pick.ts
5
- import process8 from "process";
6
-
5
+ import process10 from "process";
7
6
  // ../kit/src/args.ts
8
- import process3 from "process";
7
+ import process4 from "process";
9
8
  import { parseArgs } from "util";
10
9
 
11
10
  // ../kit/src/style.ts
12
- import process from "process";
11
+ import process2 from "process";
13
12
 
14
13
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
15
14
  function x(s) {
@@ -273,10 +272,10 @@ function le(i = {}) {
273
272
  var t = le();
274
273
 
275
274
  // ../kit/src/style.ts
276
- function takesControlCodes(stream, env = process.env) {
275
+ function takesControlCodes(stream, env = process2.env) {
277
276
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
278
277
  }
279
- function paint(stream, env = process.env) {
278
+ function paint(stream, env = process2.env) {
280
279
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
281
280
  }
282
281
  var ROLES = {
@@ -286,7 +285,7 @@ var ROLES = {
286
285
  label: (colors) => colors.dim,
287
286
  value: (colors) => colors.bold
288
287
  };
289
- function role(name, stream, env = process.env) {
288
+ function role(name, stream, env = process2.env) {
290
289
  return ROLES[name](paint(stream, env));
291
290
  }
292
291
  var STATUSES = {
@@ -306,24 +305,30 @@ function upTo(text, separator) {
306
305
  var ESCAPE = String.fromCharCode(27);
307
306
 
308
307
  // ../kit/src/help.ts
309
- import process2 from "process";
308
+ import process3 from "process";
310
309
  var OPTIONAL = /\[[^\]]+\]/g;
311
310
  var USAGE_PREFIX = /^usage:\s*/i;
312
311
  var FULL_STOP = /\.$/;
313
- function usageLine(usage, colors = paint(process2.stdout)) {
312
+ function usageLine(usage, colors = paint(process3.stdout)) {
314
313
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
315
314
  }
316
- function helpText(usage, options, colors = paint(process2.stdout), { examples = [], replaces } = {}) {
317
- return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exampleRows(examples, colors)].join(`
315
+ function helpText(usage, options, colors = paint(process3.stdout), { examples = [], replaces, exits = [] } = {}) {
316
+ return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
318
317
  `);
319
318
  }
320
- function replacesRows(replaces, colors = paint(process2.stdout)) {
319
+ function exitRows(exits, colors = paint(process3.stdout)) {
320
+ if (exits.length === 0)
321
+ return [];
322
+ const width = Math.max(...exits.map(([code]) => String(code).length));
323
+ return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
324
+ }
325
+ function replacesRows(replaces, colors = paint(process3.stdout)) {
321
326
  return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
322
327
  }
323
- function wantsHelpJson(env = process2.env) {
328
+ function wantsHelpJson(env = process3.env) {
324
329
  return env.KIT_HELP === "json";
325
330
  }
326
- function description(usage, { examples = [], replaces } = {}) {
331
+ function description(usage, { examples = [], replaces, exits } = {}, options) {
327
332
  const lines = usage.replace(USAGE_PREFIX, "").split(`
328
333
  `);
329
334
  const first = lines[0];
@@ -334,15 +339,17 @@ function description(usage, { examples = [], replaces } = {}) {
334
339
  synopsis: colon === -1 ? first : first.slice(0, colon),
335
340
  summary: colon === -1 ? fallback : first.slice(colon + 2),
336
341
  ...replaces === undefined ? {} : { replaces },
337
- examples: examples.map((example) => typeof example === "string" ? { line: example } : { line: example[0], note: example[1] })
342
+ examples: examples.map((example) => typeof example === "string" ? { line: example } : { line: example[0], note: example[1] }),
343
+ ...exits === undefined ? {} : { exits: exits.map(([code, meaning]) => ({ code, meaning })) },
344
+ ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
338
345
  };
339
346
  }
340
- function exampleRows(examples, colors = paint(process2.stdout)) {
347
+ function exampleRows(examples, colors = paint(process3.stdout)) {
341
348
  if (examples.length === 0)
342
349
  return [];
343
350
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
344
351
  }
345
- function optionRows(options, colors = paint(process2.stdout)) {
352
+ function optionRows(options, colors = paint(process3.stdout)) {
346
353
  const rows = Object.entries(options).map(([name, option]) => {
347
354
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
348
355
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -419,7 +426,7 @@ var OUTPUT_OPTIONS = {
419
426
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
420
427
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
421
428
  };
422
- function applyOutput(color, plain, env = process3.env) {
429
+ function applyOutput(color, plain, env = process4.env) {
423
430
  const when = plain === true ? "never" : color ?? "auto";
424
431
  if (when === "auto")
425
432
  return;
@@ -442,7 +449,7 @@ function parse(args, usage, options, settings = {}) {
442
449
  const { own, rest } = settings.trailing === true ? splitTrailing(args, all, settings.positionals?.length ?? 0) : splitRest(args, settings.rest === true);
443
450
  let parsed;
444
451
  try {
445
- parsed = parseArgs({ args: joinDashValues(withBare(own, all), all), options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
452
+ parsed = parseArgs({ args: joinDashValues(withBare(withAliases(own, all), all), all), options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
446
453
  } catch (error) {
447
454
  const message = parseError(error);
448
455
  throw new UsageError(message, nearestOption(message, all, settings.allowNegative === true));
@@ -450,7 +457,7 @@ function parse(args, usage, options, settings = {}) {
450
457
  const values = parsed.values;
451
458
  applyOutput("color" in output ? values.color : undefined, "plain" in output ? values.plain : undefined);
452
459
  if (values.help === true) {
453
- console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings)) : helpText(usage, listing, undefined, settings));
460
+ console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings, listing)) : helpText(usage, listing, undefined, settings));
454
461
  throw new HelpShown;
455
462
  }
456
463
  checkChoices(parsed.values, all);
@@ -492,6 +499,18 @@ function listed(options, allowNegative) {
492
499
  return [...option.description === undefined ? [] : [[name, option]], [`no-${name}`, { type: "boolean", description: option.negative }]];
493
500
  }));
494
501
  }
502
+ function withAliases(args, options) {
503
+ const named = new Map(Object.entries(options).flatMap(([name, { aliases = [] }]) => aliases.map((alias) => [`--${alias}`, `--${name}`])));
504
+ if (named.size === 0)
505
+ return args;
506
+ const separator = args.indexOf("--");
507
+ const own = separator === -1 ? args : args.slice(0, separator);
508
+ return [...own.map((arg) => {
509
+ const at = arg.indexOf("=");
510
+ const current = named.get(at === -1 ? arg : arg.slice(0, at));
511
+ return current === undefined ? arg : `${current}${at === -1 ? "" : arg.slice(at)}`;
512
+ }), ...separator === -1 ? [] : args.slice(separator)];
513
+ }
495
514
  function withBare(args, options) {
496
515
  const bare = new Map(Object.entries(options).flatMap(([name, { short, optional }]) => optional === undefined ? [] : [[`--${name}`, optional], ...short === undefined ? [] : [[`-${short}`, optional]]]));
497
516
  if (bare.size === 0)
@@ -582,13 +601,15 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
582
601
  var RESET_STYLE = `${ESC}[0m`;
583
602
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
584
603
  // ../kit/src/cli.ts
585
- import process5 from "process";
604
+ import { readFileSync, realpathSync } from "fs";
605
+ import { dirname as dirname2, join as join2 } from "path";
606
+ import process6 from "process";
586
607
 
587
608
  // ../kit/src/usage.ts
588
609
  import { appendFileSync, mkdirSync } from "fs";
589
610
  import { homedir } from "os";
590
611
  import { dirname, isAbsolute, join } from "path";
591
- import process4 from "process";
612
+ import process5 from "process";
592
613
 
593
614
  // ../kit/src/logs.ts
594
615
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -602,14 +623,14 @@ var usageError;
602
623
  function noteUsageError(message) {
603
624
  usageError = message;
604
625
  }
605
- function stateHome(env = process4.env) {
626
+ function stateHome(env = process5.env) {
606
627
  const dir = env.XDG_STATE_HOME;
607
628
  return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
608
629
  }
609
- function usagePath(env = process4.env) {
630
+ function usagePath(env = process5.env) {
610
631
  return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
611
632
  }
612
- function usageRecorded(env = process4.env) {
633
+ function usageRecorded(env = process5.env) {
613
634
  const off = env.KAYNOOO_CLI_NO_USAGE;
614
635
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
615
636
  }
@@ -623,7 +644,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
623
644
  usageError = undefined;
624
645
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
625
646
  }
626
- function recordUsage(entry, env = process4.env) {
647
+ function recordUsage(entry, env = process5.env) {
627
648
  if (!usageRecorded(env))
628
649
  return;
629
650
  try {
@@ -641,8 +662,8 @@ var LEVEL_OPTIONS = {
641
662
  };
642
663
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
643
664
  function printError(prefix, message, hint, cause) {
644
- const colors = paint(process5.stderr);
645
- const styled = takesControlCodes(process5.stderr);
665
+ const colors = paint(process6.stderr);
666
+ const styled = takesControlCodes(process6.stderr);
646
667
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
647
668
  const under = (label, text, tint) => text === undefined ? "" : `
648
669
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -724,11 +745,22 @@ async function printCandidates(found) {
724
745
  console.log(line);
725
746
  return 0;
726
747
  }
727
- async function runMain({ name, version, run, redact, usage }, argv = process5.argv.slice(2)) {
748
+ function packageVersion(entry = Bun.main) {
749
+ for (let dir = dirname2(realpathSync(entry));; dir = dirname2(dir)) {
750
+ try {
751
+ const { version } = JSON.parse(readFileSync(join2(dir, "package.json"), "utf8"));
752
+ if (typeof version === "string")
753
+ return version;
754
+ } catch {}
755
+ if (dirname2(dir) === dir)
756
+ return "0.0.0";
757
+ }
758
+ }
759
+ async function runMain({ name, version, run, redact, usage }, argv = process6.argv.slice(2)) {
728
760
  if (argv[0] === COMPLETE)
729
761
  return printCandidates(leafCandidates(run, argv.slice(1)));
730
762
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
731
- console.log(version);
763
+ console.log(version ?? packageVersion());
732
764
  return 0;
733
765
  }
734
766
  let code;
@@ -737,8 +769,11 @@ async function runMain({ name, version, run, redact, usage }, argv = process5.ar
737
769
  } catch (error) {
738
770
  code = reportThrown(name, error, redact, wantsJson(argv));
739
771
  }
740
- if (usage !== false)
741
- recordUsage(usageEntry(name, undefined, argv, code));
772
+ if (usage !== false) {
773
+ try {
774
+ recordUsage(usageEntry(name, undefined, argv, code));
775
+ } catch {}
776
+ }
742
777
  return code;
743
778
  }
744
779
  // ../kit/src/secrets.ts
@@ -747,14 +782,14 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
747
782
  var {Glob } = globalThis.Bun;
748
783
  var SESSION_FILES = new Glob("*.json");
749
784
  var ACCOUNT_DIRS = new Glob("*/sessions");
750
- // package.json
751
- var version = "0.1.0";
752
-
753
785
  // src/terminal.ts
754
786
  import { openSync } from "fs";
755
- import process7 from "process";
787
+ import process9 from "process";
756
788
  import tty from "tty";
757
789
 
790
+ // src/preview.ts
791
+ import process8 from "process";
792
+
758
793
  // ../kit/src/shell.ts
759
794
  var SEPARATORS = new Set([`
760
795
  `, ";", "|"]);
@@ -764,13 +799,16 @@ var COMMENT_PREFIXES = new Set([";", "&", "|", "(", ")"]);
764
799
  var SAFE_WORD = /^[\w@%+=:,./-]+$/;
765
800
  var DOUBLE_QUOTED_ESCAPES = new Set(["$", "`", '"', "\\"]);
766
801
  var KEYWORDS = new Set(["then", "do", "else", "if", "elif", "while", "until", "!", "{", "}"]);
767
- var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh"]);
768
- var COMMAND_STRING_PROGRAMS = new Set([...SHELLS, "su", "runuser"]);
802
+ var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh", "fish", "csh", "tcsh", "nu", "xonsh", "elvish", "pwsh", "powershell"]);
803
+ var SCANNED_PROGRAMS = new Set(["su", "runuser", "flock"]);
804
+ var COMMAND_STRING_PROGRAMS = new Set([...SHELLS, ...SCANNED_PROGRAMS]);
805
+ var POWERSHELL = new Set(["pwsh", "powershell"]);
769
806
  var SHELL_VALUE_OPTIONS = new Set(["-o", "-O", "--rcfile", "--init-file"]);
807
+ var FISH_VALUE_OPTIONS = new Set(["-C", "--init-command"]);
770
808
  var PRINTERS = new Set(["echo", "printf"]);
771
809
  var FIND_EXEC = new Set(["-exec", "-execdir", "-ok", "-okdir"]);
772
- function wrapper(short = "", long = [], operands = 0) {
773
- return { short, long, operands };
810
+ function wrapper(short = "", long = [], operands = 0, runsString = false) {
811
+ return { short, long, operands, runsString };
774
812
  }
775
813
  var WRAPPERS = new Map([
776
814
  ["command", wrapper()],
@@ -788,6 +826,11 @@ var WRAPPERS = new Map([
788
826
  ["ionice", wrapper("cnpPu", ["--class", "--classdata", "--pid", "--pgid", "--uid"])],
789
827
  ["stdbuf", wrapper("ioe", ["--input", "--output", "--error"])],
790
828
  ["chroot", wrapper("", ["--userspec", "--groups"], 1)],
829
+ ["watch", wrapper("n", ["--interval"], 0, true)],
830
+ ["flock", wrapper("wE", ["--timeout", "--conflict-exit-code"], 1)],
831
+ ["parallel", wrapper("jnNSaIPlLdTsC", ["--jobs", "--max-args", "--max-replace-args", "--sshlogin", "--arg-file", "--delimiter", "--colsep"], 0, true)],
832
+ ["unbuffer", wrapper()],
833
+ ["systemd-run", wrapper("puEMH", ["--property", "--unit", "--description", "--slice", "--setenv", "--machine", "--host", "--uid", "--gid", "--working-directory", "--nice", "--service-type"])],
791
834
  ["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])]
792
835
  ]);
793
836
  function shellQuote(word) {
@@ -881,8 +924,10 @@ function rank(query, lines) {
881
924
  var ANSI2 = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
882
925
  var CONTROL = /[\x00-\x1F\x7F-\x9F]/g;
883
926
  var IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
927
+ var PASTE_START = "\x1B[200~";
928
+ var PASTE_END = "\x1B[201~";
884
929
  var LAST_WORD = /\S*\s*$/;
885
- var KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|[\s\S]/gu;
930
+ var KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
886
931
  var KEYS = {
887
932
  "\x1B[A": "up",
888
933
  "\x1BOA": "up",
@@ -903,9 +948,16 @@ var KEYS = {
903
948
  function displayed(line) {
904
949
  return line.replace(ANSI2, "").replace(CONTROL, " ");
905
950
  }
906
- function parseKeys(input) {
951
+ function parseKeys(input, paste = { active: false }) {
907
952
  return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
908
953
  const key = KEYS[sequence];
954
+ if (sequence === PASTE_START || sequence === PASTE_END) {
955
+ paste.active = sequence === PASTE_START;
956
+ return [];
957
+ }
958
+ if (paste.active && (sequence === "\r" || sequence === `
959
+ `))
960
+ return [];
909
961
  if (key !== undefined)
910
962
  return [key];
911
963
  return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
@@ -978,8 +1030,14 @@ function previewLines(output) {
978
1030
  }
979
1031
  async function runPreview(template, line, signal) {
980
1032
  const proc = Bun.spawn(["sh", "-c", `exec 2>&1
981
- ${previewCommand(template, line)}`], { stdin: "ignore", stdout: "pipe", stderr: "ignore" });
982
- const stop = () => proc.kill();
1033
+ ${previewCommand(template, line)}`], { stdin: "ignore", stdout: "pipe", stderr: "ignore", detached: true });
1034
+ const stop = () => {
1035
+ try {
1036
+ process8.kill(-proc.pid, "SIGKILL");
1037
+ } catch {
1038
+ proc.kill();
1039
+ }
1040
+ };
983
1041
  const timer = setTimeout(stop, PREVIEW_TIMEOUT_MS);
984
1042
  const chunks = [];
985
1043
  let size = 0;
@@ -1076,6 +1134,8 @@ function render(state, layout, theme, preview = []) {
1076
1134
  var PREVIEW_DELAY_MS = 120;
1077
1135
  var HIDE_CURSOR = "\x1B[?25l";
1078
1136
  var SHOW_CURSOR = "\x1B[?25h";
1137
+ var PASTE_ON = "\x1B[?2004h";
1138
+ var PASTE_OFF = "\x1B[?2004l";
1079
1139
  var CLEAR_BELOW = "\r\x1B[J";
1080
1140
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
1081
1141
  function themeFor(stream) {
@@ -1091,7 +1151,7 @@ async function choose(lines, settings) {
1091
1151
  } catch {
1092
1152
  return fail("no terminal to read keys from (/dev/tty)");
1093
1153
  }
1094
- const out = process7.stderr;
1154
+ const out = process9.stderr;
1095
1155
  const theme = themeFor(out);
1096
1156
  let state = createState(lines, settings);
1097
1157
  let preview = [];
@@ -1143,7 +1203,7 @@ async function choose(lines, settings) {
1143
1203
  restored = true;
1144
1204
  clearTimeout(previewTimer);
1145
1205
  previewing.abort();
1146
- out.write(`${CLEAR_BELOW}${SHOW_CURSOR}`);
1206
+ out.write(`${CLEAR_BELOW}${PASTE_OFF}${SHOW_CURSOR}`);
1147
1207
  out.off("resize", onResize);
1148
1208
  try {
1149
1209
  input.setRawMode(false);
@@ -1151,11 +1211,12 @@ async function choose(lines, settings) {
1151
1211
  input.destroy();
1152
1212
  }
1153
1213
  }
1214
+ const paste = { active: false };
1154
1215
  function onResize() {
1155
1216
  draw(true);
1156
1217
  }
1157
1218
  function onData(chunk) {
1158
- for (const key of parseKeys(chunk.toString())) {
1219
+ for (const key of parseKeys(chunk.toString(), paste)) {
1159
1220
  state = press(state, key);
1160
1221
  if (state.done !== undefined) {
1161
1222
  finish?.();
@@ -1172,11 +1233,12 @@ async function choose(lines, settings) {
1172
1233
  const ended = new Promise((resolve) => {
1173
1234
  finish = resolve;
1174
1235
  });
1175
- process7.once("exit", restore);
1236
+ process9.once("exit", restore);
1176
1237
  for (const signal of SIGNALS)
1177
- process7.once(signal, stop);
1238
+ process9.once(signal, stop);
1178
1239
  try {
1179
1240
  input.setRawMode(true);
1241
+ out.write(PASTE_ON);
1180
1242
  out.on("resize", onResize);
1181
1243
  input.on("data", onData);
1182
1244
  refreshPreview();
@@ -1184,8 +1246,8 @@ async function choose(lines, settings) {
1184
1246
  await ended;
1185
1247
  } finally {
1186
1248
  for (const signal of SIGNALS)
1187
- process7.off(signal, stop);
1188
- process7.off("exit", restore);
1249
+ process9.off(signal, stop);
1250
+ process9.off("exit", restore);
1189
1251
  restore();
1190
1252
  }
1191
1253
  return state.done === "accept" ? chosen(state) : undefined;
@@ -1213,9 +1275,9 @@ async function main(args) {
1213
1275
  const height = values.height === undefined ? DEFAULT_HEIGHT : parseHeight(values.height);
1214
1276
  if (height === undefined)
1215
1277
  badUsage(`--height takes a number of lines or a percentage such as 40%, not ${values.height}`);
1216
- if (!process8.stderr.isTTY)
1278
+ if (!process10.stderr.isTTY)
1217
1279
  fail("pick draws on stderr and it is not a terminal");
1218
- if (process8.stdin.isTTY)
1280
+ if (process10.stdin.isTTY)
1219
1281
  badUsage("pipe the lines to pick on stdin");
1220
1282
  const lines = (await Bun.stdin.text()).split(`
1221
1283
  `).filter((line) => line !== "");
@@ -1224,9 +1286,9 @@ async function main(args) {
1224
1286
  const picked = await choose(lines, { multi: values.multi === true, prompt: values.prompt ?? "> ", query: values.query ?? "", height, preview: values.preview });
1225
1287
  if (picked === undefined)
1226
1288
  return 1;
1227
- process8.stdout.write(`${picked.join(`
1289
+ process10.stdout.write(`${picked.join(`
1228
1290
  `)}
1229
1291
  `);
1230
1292
  return 0;
1231
1293
  }
1232
- process8.exitCode = await runMain({ name: "pick", version, run: main });
1294
+ process10.exitCode = await runMain({ name: "pick", run: main });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-pick",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.2.1",
5
5
  "description": "pick: a themed fuzzy selector, lines on stdin, the chosen one on stdout.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -35,6 +35,6 @@
35
35
  "pick": "$npm_execpath src/pick.ts"
36
36
  },
37
37
  "devDependencies": {
38
- "@kaynooo/cli-kit": "0.19.0"
38
+ "@kaynooo/cli-kit": "0.21.0"
39
39
  }
40
40
  }