@kaynooo/cli-git 0.17.1 → 0.17.2
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/README.md +1 -1
- package/dist/gb.js +43 -13
- package/dist/gc.js +39 -9
- package/dist/gcl.js +41 -11
- package/dist/gd.js +39 -9
- package/dist/gf.js +39 -9
- package/dist/gm.js +46 -18
- package/dist/gp.js +40 -10
- package/dist/gst.js +39 -9
- package/dist/gu.js +41 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ Prints one line with the branch, its upstream and how far ahead and behind it is
|
|
|
57
57
|
|
|
58
58
|
- On a conflict every conflicted file is listed with its conflict regions (the markers and two lines around them, line numbers included) and the exit is 1; `gm --continue` commits once the markers are gone, refusing while one remains, and `gm --abort` gives the merge up.
|
|
59
59
|
- `gm --dry-run <branch>` says whether the merge would conflict, and in which files, with `git merge-tree` and nothing touched.
|
|
60
|
-
- `--squash` stages the branch's changes without committing them, to commit with `gc
|
|
60
|
+
- `--squash` stages the branch's changes without committing them or recording a merge, to commit with `gc`; a conflict then leaves the files to resolve and `git reset --merge` gives up.
|
|
61
61
|
- With no branch, a terminal gets a picker of the other branches (ahead and behind the current one, a preview of the commits, files and verdict; enter merges, ctrl-s squashes); without a terminal the branches are listed with their verdict, `--json` giving `[{name, ahead, behind, outcome, conflicts}]`.
|
|
62
62
|
- Exit codes: 0 merged, already merged or no conflict in a dry run, 1 a conflict, a dirty tree or a refusal, 2 outside a repository or a usage error.
|
|
63
63
|
|
package/dist/gb.js
CHANGED
|
@@ -530,7 +530,27 @@ var init_format = __esm(() => {
|
|
|
530
530
|
// ../kit/src/help.ts
|
|
531
531
|
import process8 from "process";
|
|
532
532
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
533
|
-
|
|
533
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
534
|
+
`);
|
|
535
|
+
const blank = lines.indexOf("");
|
|
536
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
537
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
538
|
+
const colon = synopses[0].indexOf(": ");
|
|
539
|
+
const inline = synopses[0].slice(colon + 2);
|
|
540
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
541
|
+
if (colon !== -1)
|
|
542
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
543
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
544
|
+
`)}`;
|
|
545
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
546
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
547
|
+
return [head, ...lead, ...rest].join(`
|
|
548
|
+
`);
|
|
549
|
+
}
|
|
550
|
+
function prose(line, colors) {
|
|
551
|
+
if (colors.cyan("x") === "x")
|
|
552
|
+
return line;
|
|
553
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
534
554
|
}
|
|
535
555
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
536
556
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -579,13 +599,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
579
599
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
580
600
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
581
601
|
}
|
|
582
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
602
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
583
603
|
var init_help = __esm(() => {
|
|
584
604
|
init_mode();
|
|
585
605
|
init_style();
|
|
586
606
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
587
607
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
588
608
|
FULL_STOP = /\.$/;
|
|
609
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
589
610
|
});
|
|
590
611
|
|
|
591
612
|
// ../kit/src/text.ts
|
|
@@ -836,7 +857,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
836
857
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
837
858
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
838
859
|
}
|
|
839
|
-
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
860
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
840
861
|
var init_args = __esm(() => {
|
|
841
862
|
init_format();
|
|
842
863
|
init_help();
|
|
@@ -844,14 +865,21 @@ var init_args = __esm(() => {
|
|
|
844
865
|
init_help();
|
|
845
866
|
init_input();
|
|
846
867
|
DASHES = /^-+/;
|
|
868
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
847
869
|
Exit = class Exit extends Error {
|
|
848
870
|
code;
|
|
849
871
|
hint;
|
|
872
|
+
[EXIT] = true;
|
|
850
873
|
constructor(message, code, hint) {
|
|
851
874
|
super(message);
|
|
852
875
|
this.code = code;
|
|
853
876
|
this.hint = hint;
|
|
854
877
|
}
|
|
878
|
+
static [Symbol.hasInstance](value) {
|
|
879
|
+
if (this !== Exit)
|
|
880
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
881
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
882
|
+
}
|
|
855
883
|
};
|
|
856
884
|
UsageError = class UsageError extends Exit {
|
|
857
885
|
constructor(message, hint) {
|
|
@@ -1595,10 +1623,10 @@ function holdSignals(cleanup) {
|
|
|
1595
1623
|
process11.on(signal, onSignal);
|
|
1596
1624
|
return held;
|
|
1597
1625
|
}
|
|
1598
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1626
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1599
1627
|
const chunks = [];
|
|
1600
1628
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
1601
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1629
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1602
1630
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
1603
1631
|
const timers = [];
|
|
1604
1632
|
const killGroup = (killing) => {
|
|
@@ -1912,7 +1940,9 @@ import process16 from "process";
|
|
|
1912
1940
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1913
1941
|
var ECHOED = /username|yes\/no/i;
|
|
1914
1942
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1915
|
-
function askpass(pause) {
|
|
1943
|
+
function askpass(pause = () => () => {
|
|
1944
|
+
return;
|
|
1945
|
+
}) {
|
|
1916
1946
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1917
1947
|
return;
|
|
1918
1948
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
@@ -2130,10 +2160,10 @@ function flagNames(argv) {
|
|
|
2130
2160
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
2131
2161
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
2132
2162
|
}
|
|
2133
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
2163
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
2134
2164
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
2135
2165
|
usageError = undefined;
|
|
2136
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
2166
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
2137
2167
|
}
|
|
2138
2168
|
function recordUsage(entry, env = process18.env) {
|
|
2139
2169
|
if (!usageRecorded(env))
|
|
@@ -2293,7 +2323,7 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
2293
2323
|
notifyEnd(name, code, performance.now() - started);
|
|
2294
2324
|
if (usage !== false) {
|
|
2295
2325
|
try {
|
|
2296
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
2326
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
2297
2327
|
} catch {}
|
|
2298
2328
|
}
|
|
2299
2329
|
return code;
|
|
@@ -2910,14 +2940,14 @@ function list(rows) {
|
|
|
2910
2940
|
}
|
|
2911
2941
|
|
|
2912
2942
|
// src/branch.ts
|
|
2913
|
-
var usage2 = `gb [branch]
|
|
2943
|
+
var usage2 = `gb [branch]: picks a git branch and switches to it
|
|
2914
2944
|
gb -
|
|
2915
2945
|
gb -c <name>
|
|
2916
2946
|
gb -d <branch>
|
|
2917
2947
|
|
|
2918
|
-
Without a branch,
|
|
2919
|
-
\`gb <branch>\` switches without the picker,
|
|
2920
|
-
A branch checked out in another worktree cannot be switched to: gb prints that worktree's path
|
|
2948
|
+
Without a branch, on a terminal, picks one: the recently checked out first, then the other local ones, then the remote ones with no local branch yet (enter switches, ctrl-n creates, ctrl-d deletes a merged local branch with \`git branch -d\`, ctrl-r fetches and prunes); without a terminal it lists them.
|
|
2949
|
+
\`gb <branch>\` switches without the picker, \`gb -\` goes back to the previous branch, \`gb -c <name>\` creates one and switches to it, \`gb -d <branch>\` deletes a local one.
|
|
2950
|
+
A branch checked out in another worktree cannot be switched to: gb prints that worktree's path, since a command cannot change its shell's folder.`;
|
|
2921
2951
|
var EXITS = [[0, "it switched, created, deleted or listed"], ["git", "the code of the git command it ran, when that failed"], [1, "there is no branch by that name or nothing was picked"], [2, "outside a git repository or a usage error"]];
|
|
2922
2952
|
var options = {
|
|
2923
2953
|
create: { type: "boolean", short: "c", description: "create the branch named by the rest of the line and switch to it" },
|
package/dist/gc.js
CHANGED
|
@@ -530,7 +530,27 @@ var init_format = __esm(() => {
|
|
|
530
530
|
// ../kit/src/help.ts
|
|
531
531
|
import process8 from "process";
|
|
532
532
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
533
|
-
|
|
533
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
534
|
+
`);
|
|
535
|
+
const blank = lines.indexOf("");
|
|
536
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
537
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
538
|
+
const colon = synopses[0].indexOf(": ");
|
|
539
|
+
const inline = synopses[0].slice(colon + 2);
|
|
540
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
541
|
+
if (colon !== -1)
|
|
542
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
543
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
544
|
+
`)}`;
|
|
545
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
546
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
547
|
+
return [head, ...lead, ...rest].join(`
|
|
548
|
+
`);
|
|
549
|
+
}
|
|
550
|
+
function prose(line, colors) {
|
|
551
|
+
if (colors.cyan("x") === "x")
|
|
552
|
+
return line;
|
|
553
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
534
554
|
}
|
|
535
555
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
536
556
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -579,13 +599,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
579
599
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
580
600
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
581
601
|
}
|
|
582
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
602
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
583
603
|
var init_help = __esm(() => {
|
|
584
604
|
init_mode();
|
|
585
605
|
init_style();
|
|
586
606
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
587
607
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
588
608
|
FULL_STOP = /\.$/;
|
|
609
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
589
610
|
});
|
|
590
611
|
|
|
591
612
|
// ../kit/src/text.ts
|
|
@@ -836,7 +857,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
836
857
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
837
858
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
838
859
|
}
|
|
839
|
-
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
860
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
840
861
|
var init_args = __esm(() => {
|
|
841
862
|
init_format();
|
|
842
863
|
init_help();
|
|
@@ -844,14 +865,21 @@ var init_args = __esm(() => {
|
|
|
844
865
|
init_help();
|
|
845
866
|
init_input();
|
|
846
867
|
DASHES = /^-+/;
|
|
868
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
847
869
|
Exit = class Exit extends Error {
|
|
848
870
|
code;
|
|
849
871
|
hint;
|
|
872
|
+
[EXIT] = true;
|
|
850
873
|
constructor(message, code, hint) {
|
|
851
874
|
super(message);
|
|
852
875
|
this.code = code;
|
|
853
876
|
this.hint = hint;
|
|
854
877
|
}
|
|
878
|
+
static [Symbol.hasInstance](value) {
|
|
879
|
+
if (this !== Exit)
|
|
880
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
881
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
882
|
+
}
|
|
855
883
|
};
|
|
856
884
|
UsageError = class UsageError extends Exit {
|
|
857
885
|
constructor(message, hint) {
|
|
@@ -1595,10 +1623,10 @@ function holdSignals(cleanup) {
|
|
|
1595
1623
|
process11.on(signal, onSignal);
|
|
1596
1624
|
return held;
|
|
1597
1625
|
}
|
|
1598
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1626
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1599
1627
|
const chunks = [];
|
|
1600
1628
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
1601
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1629
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1602
1630
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
1603
1631
|
const timers = [];
|
|
1604
1632
|
const killGroup = (killing) => {
|
|
@@ -1912,7 +1940,9 @@ import process16 from "process";
|
|
|
1912
1940
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1913
1941
|
var ECHOED = /username|yes\/no/i;
|
|
1914
1942
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1915
|
-
function askpass(pause) {
|
|
1943
|
+
function askpass(pause = () => () => {
|
|
1944
|
+
return;
|
|
1945
|
+
}) {
|
|
1916
1946
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1917
1947
|
return;
|
|
1918
1948
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
@@ -2130,10 +2160,10 @@ function flagNames(argv) {
|
|
|
2130
2160
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
2131
2161
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
2132
2162
|
}
|
|
2133
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
2163
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
2134
2164
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
2135
2165
|
usageError = undefined;
|
|
2136
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
2166
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
2137
2167
|
}
|
|
2138
2168
|
function recordUsage(entry, env = process18.env) {
|
|
2139
2169
|
if (!usageRecorded(env))
|
|
@@ -2293,7 +2323,7 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
2293
2323
|
notifyEnd(name, code, performance.now() - started);
|
|
2294
2324
|
if (usage !== false) {
|
|
2295
2325
|
try {
|
|
2296
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
2326
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
2297
2327
|
} catch {}
|
|
2298
2328
|
}
|
|
2299
2329
|
return code;
|
package/dist/gcl.js
CHANGED
|
@@ -530,7 +530,27 @@ var init_format = __esm(() => {
|
|
|
530
530
|
// ../kit/src/help.ts
|
|
531
531
|
import process8 from "process";
|
|
532
532
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
533
|
-
|
|
533
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
534
|
+
`);
|
|
535
|
+
const blank = lines.indexOf("");
|
|
536
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
537
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
538
|
+
const colon = synopses[0].indexOf(": ");
|
|
539
|
+
const inline = synopses[0].slice(colon + 2);
|
|
540
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
541
|
+
if (colon !== -1)
|
|
542
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
543
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
544
|
+
`)}`;
|
|
545
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
546
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
547
|
+
return [head, ...lead, ...rest].join(`
|
|
548
|
+
`);
|
|
549
|
+
}
|
|
550
|
+
function prose(line, colors) {
|
|
551
|
+
if (colors.cyan("x") === "x")
|
|
552
|
+
return line;
|
|
553
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
534
554
|
}
|
|
535
555
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
536
556
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -579,13 +599,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
579
599
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
580
600
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
581
601
|
}
|
|
582
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
602
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
583
603
|
var init_help = __esm(() => {
|
|
584
604
|
init_mode();
|
|
585
605
|
init_style();
|
|
586
606
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
587
607
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
588
608
|
FULL_STOP = /\.$/;
|
|
609
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
589
610
|
});
|
|
590
611
|
|
|
591
612
|
// ../kit/src/text.ts
|
|
@@ -836,7 +857,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
836
857
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
837
858
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
838
859
|
}
|
|
839
|
-
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
860
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
840
861
|
var init_args = __esm(() => {
|
|
841
862
|
init_format();
|
|
842
863
|
init_help();
|
|
@@ -844,14 +865,21 @@ var init_args = __esm(() => {
|
|
|
844
865
|
init_help();
|
|
845
866
|
init_input();
|
|
846
867
|
DASHES = /^-+/;
|
|
868
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
847
869
|
Exit = class Exit extends Error {
|
|
848
870
|
code;
|
|
849
871
|
hint;
|
|
872
|
+
[EXIT] = true;
|
|
850
873
|
constructor(message, code, hint) {
|
|
851
874
|
super(message);
|
|
852
875
|
this.code = code;
|
|
853
876
|
this.hint = hint;
|
|
854
877
|
}
|
|
878
|
+
static [Symbol.hasInstance](value) {
|
|
879
|
+
if (this !== Exit)
|
|
880
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
881
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
882
|
+
}
|
|
855
883
|
};
|
|
856
884
|
UsageError = class UsageError extends Exit {
|
|
857
885
|
constructor(message, hint) {
|
|
@@ -1598,10 +1626,10 @@ function holdSignals(cleanup) {
|
|
|
1598
1626
|
process11.on(signal, onSignal);
|
|
1599
1627
|
return held;
|
|
1600
1628
|
}
|
|
1601
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1629
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1602
1630
|
const chunks = [];
|
|
1603
1631
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
1604
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1632
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1605
1633
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
1606
1634
|
const timers = [];
|
|
1607
1635
|
const killGroup = (killing) => {
|
|
@@ -1915,7 +1943,9 @@ import process16 from "process";
|
|
|
1915
1943
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1916
1944
|
var ECHOED = /username|yes\/no/i;
|
|
1917
1945
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1918
|
-
function askpass(pause) {
|
|
1946
|
+
function askpass(pause = () => () => {
|
|
1947
|
+
return;
|
|
1948
|
+
}) {
|
|
1919
1949
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1920
1950
|
return;
|
|
1921
1951
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
@@ -2133,10 +2163,10 @@ function flagNames(argv) {
|
|
|
2133
2163
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
2134
2164
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
2135
2165
|
}
|
|
2136
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
2166
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
2137
2167
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
2138
2168
|
usageError = undefined;
|
|
2139
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
2169
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
2140
2170
|
}
|
|
2141
2171
|
function recordUsage(entry, env = process18.env) {
|
|
2142
2172
|
if (!usageRecorded(env))
|
|
@@ -2296,7 +2326,7 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
2296
2326
|
notifyEnd(name, code, performance.now() - started);
|
|
2297
2327
|
if (usage !== false) {
|
|
2298
2328
|
try {
|
|
2299
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
2329
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
2300
2330
|
} catch {}
|
|
2301
2331
|
}
|
|
2302
2332
|
return code;
|
|
@@ -2626,8 +2656,8 @@ async function sync(repo, { pull, env }) {
|
|
|
2626
2656
|
var DEFAULT_FORGE = "git.kaynooo.fr";
|
|
2627
2657
|
var USAGE = `gcl <repo> [dir]: clones a repository into the workspace folder and prints where it landed
|
|
2628
2658
|
|
|
2629
|
-
<repo> is a URL, an scp-style address
|
|
2630
|
-
|
|
2659
|
+
<repo> is a URL, an scp-style address, a local path or \`owner/name\`, read as \`https://${DEFAULT_FORGE}/owner/name.git\` (the \`forge\` config key names another host). Without <dir> the clone goes to <workspace>/<name>, the workspace \`cli config\` reports.
|
|
2660
|
+
A folder that already holds the repository is fetched and fast-forwarded as gf does, not cloned again; one holding anything else is refused.`;
|
|
2631
2661
|
var EXITS = [[0, "it cloned the repository, or found it and brought it up to date"], [1, "git could not clone it, or the folder is taken"], [2, "a usage error"]];
|
|
2632
2662
|
var OPTIONS = {
|
|
2633
2663
|
json: jsonOption("{url, path, branch, head, outcome}, outcome being cloned or existing")
|
package/dist/gd.js
CHANGED
|
@@ -530,7 +530,27 @@ var init_format = __esm(() => {
|
|
|
530
530
|
// ../kit/src/help.ts
|
|
531
531
|
import process8 from "process";
|
|
532
532
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
533
|
-
|
|
533
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
534
|
+
`);
|
|
535
|
+
const blank = lines.indexOf("");
|
|
536
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
537
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
538
|
+
const colon = synopses[0].indexOf(": ");
|
|
539
|
+
const inline = synopses[0].slice(colon + 2);
|
|
540
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
541
|
+
if (colon !== -1)
|
|
542
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
543
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
544
|
+
`)}`;
|
|
545
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
546
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
547
|
+
return [head, ...lead, ...rest].join(`
|
|
548
|
+
`);
|
|
549
|
+
}
|
|
550
|
+
function prose(line, colors) {
|
|
551
|
+
if (colors.cyan("x") === "x")
|
|
552
|
+
return line;
|
|
553
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
534
554
|
}
|
|
535
555
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
536
556
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -579,13 +599,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
579
599
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
580
600
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
581
601
|
}
|
|
582
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
602
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
583
603
|
var init_help = __esm(() => {
|
|
584
604
|
init_mode();
|
|
585
605
|
init_style();
|
|
586
606
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
587
607
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
588
608
|
FULL_STOP = /\.$/;
|
|
609
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
589
610
|
});
|
|
590
611
|
|
|
591
612
|
// ../kit/src/text.ts
|
|
@@ -836,7 +857,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
836
857
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
837
858
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
838
859
|
}
|
|
839
|
-
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
860
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
840
861
|
var init_args = __esm(() => {
|
|
841
862
|
init_format();
|
|
842
863
|
init_help();
|
|
@@ -844,14 +865,21 @@ var init_args = __esm(() => {
|
|
|
844
865
|
init_help();
|
|
845
866
|
init_input();
|
|
846
867
|
DASHES = /^-+/;
|
|
868
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
847
869
|
Exit = class Exit extends Error {
|
|
848
870
|
code;
|
|
849
871
|
hint;
|
|
872
|
+
[EXIT] = true;
|
|
850
873
|
constructor(message, code, hint) {
|
|
851
874
|
super(message);
|
|
852
875
|
this.code = code;
|
|
853
876
|
this.hint = hint;
|
|
854
877
|
}
|
|
878
|
+
static [Symbol.hasInstance](value) {
|
|
879
|
+
if (this !== Exit)
|
|
880
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
881
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
882
|
+
}
|
|
855
883
|
};
|
|
856
884
|
UsageError = class UsageError extends Exit {
|
|
857
885
|
constructor(message, hint) {
|
|
@@ -1595,10 +1623,10 @@ function holdSignals(cleanup) {
|
|
|
1595
1623
|
process11.on(signal, onSignal);
|
|
1596
1624
|
return held;
|
|
1597
1625
|
}
|
|
1598
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1626
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1599
1627
|
const chunks = [];
|
|
1600
1628
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
1601
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1629
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1602
1630
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
1603
1631
|
const timers = [];
|
|
1604
1632
|
const killGroup = (killing) => {
|
|
@@ -1912,7 +1940,9 @@ import process16 from "process";
|
|
|
1912
1940
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1913
1941
|
var ECHOED = /username|yes\/no/i;
|
|
1914
1942
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1915
|
-
function askpass(pause) {
|
|
1943
|
+
function askpass(pause = () => () => {
|
|
1944
|
+
return;
|
|
1945
|
+
}) {
|
|
1916
1946
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1917
1947
|
return;
|
|
1918
1948
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
@@ -2130,10 +2160,10 @@ function flagNames(argv) {
|
|
|
2130
2160
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
2131
2161
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
2132
2162
|
}
|
|
2133
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
2163
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
2134
2164
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
2135
2165
|
usageError = undefined;
|
|
2136
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
2166
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
2137
2167
|
}
|
|
2138
2168
|
function recordUsage(entry, env = process18.env) {
|
|
2139
2169
|
if (!usageRecorded(env))
|
|
@@ -2293,7 +2323,7 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
2293
2323
|
notifyEnd(name, code, performance.now() - started);
|
|
2294
2324
|
if (usage !== false) {
|
|
2295
2325
|
try {
|
|
2296
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
2326
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
2297
2327
|
} catch {}
|
|
2298
2328
|
}
|
|
2299
2329
|
return code;
|
package/dist/gf.js
CHANGED
|
@@ -530,7 +530,27 @@ var init_format = __esm(() => {
|
|
|
530
530
|
// ../kit/src/help.ts
|
|
531
531
|
import process8 from "process";
|
|
532
532
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
533
|
-
|
|
533
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
534
|
+
`);
|
|
535
|
+
const blank = lines.indexOf("");
|
|
536
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
537
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
538
|
+
const colon = synopses[0].indexOf(": ");
|
|
539
|
+
const inline = synopses[0].slice(colon + 2);
|
|
540
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
541
|
+
if (colon !== -1)
|
|
542
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
543
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
544
|
+
`)}`;
|
|
545
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
546
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
547
|
+
return [head, ...lead, ...rest].join(`
|
|
548
|
+
`);
|
|
549
|
+
}
|
|
550
|
+
function prose(line, colors) {
|
|
551
|
+
if (colors.cyan("x") === "x")
|
|
552
|
+
return line;
|
|
553
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
534
554
|
}
|
|
535
555
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
536
556
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -579,13 +599,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
579
599
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
580
600
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
581
601
|
}
|
|
582
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
602
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
583
603
|
var init_help = __esm(() => {
|
|
584
604
|
init_mode();
|
|
585
605
|
init_style();
|
|
586
606
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
587
607
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
588
608
|
FULL_STOP = /\.$/;
|
|
609
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
589
610
|
});
|
|
590
611
|
|
|
591
612
|
// ../kit/src/text.ts
|
|
@@ -836,7 +857,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
836
857
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
837
858
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
838
859
|
}
|
|
839
|
-
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
860
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
840
861
|
var init_args = __esm(() => {
|
|
841
862
|
init_format();
|
|
842
863
|
init_help();
|
|
@@ -844,14 +865,21 @@ var init_args = __esm(() => {
|
|
|
844
865
|
init_help();
|
|
845
866
|
init_input();
|
|
846
867
|
DASHES = /^-+/;
|
|
868
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
847
869
|
Exit = class Exit extends Error {
|
|
848
870
|
code;
|
|
849
871
|
hint;
|
|
872
|
+
[EXIT] = true;
|
|
850
873
|
constructor(message, code, hint) {
|
|
851
874
|
super(message);
|
|
852
875
|
this.code = code;
|
|
853
876
|
this.hint = hint;
|
|
854
877
|
}
|
|
878
|
+
static [Symbol.hasInstance](value) {
|
|
879
|
+
if (this !== Exit)
|
|
880
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
881
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
882
|
+
}
|
|
855
883
|
};
|
|
856
884
|
UsageError = class UsageError extends Exit {
|
|
857
885
|
constructor(message, hint) {
|
|
@@ -1595,10 +1623,10 @@ function holdSignals(cleanup) {
|
|
|
1595
1623
|
process11.on(signal, onSignal);
|
|
1596
1624
|
return held;
|
|
1597
1625
|
}
|
|
1598
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1626
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1599
1627
|
const chunks = [];
|
|
1600
1628
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
1601
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1629
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1602
1630
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
1603
1631
|
const timers = [];
|
|
1604
1632
|
const killGroup = (killing) => {
|
|
@@ -1912,7 +1940,9 @@ import process16 from "process";
|
|
|
1912
1940
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1913
1941
|
var ECHOED = /username|yes\/no/i;
|
|
1914
1942
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1915
|
-
function askpass(pause) {
|
|
1943
|
+
function askpass(pause = () => () => {
|
|
1944
|
+
return;
|
|
1945
|
+
}) {
|
|
1916
1946
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1917
1947
|
return;
|
|
1918
1948
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
@@ -2130,10 +2160,10 @@ function flagNames(argv) {
|
|
|
2130
2160
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
2131
2161
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
2132
2162
|
}
|
|
2133
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
2163
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
2134
2164
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
2135
2165
|
usageError = undefined;
|
|
2136
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
2166
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
2137
2167
|
}
|
|
2138
2168
|
function recordUsage(entry, env = process18.env) {
|
|
2139
2169
|
if (!usageRecorded(env))
|
|
@@ -2293,7 +2323,7 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
2293
2323
|
notifyEnd(name, code, performance.now() - started);
|
|
2294
2324
|
if (usage !== false) {
|
|
2295
2325
|
try {
|
|
2296
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
2326
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
2297
2327
|
} catch {}
|
|
2298
2328
|
}
|
|
2299
2329
|
return code;
|
package/dist/gm.js
CHANGED
|
@@ -530,7 +530,27 @@ var init_format = __esm(() => {
|
|
|
530
530
|
// ../kit/src/help.ts
|
|
531
531
|
import process8 from "process";
|
|
532
532
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
533
|
-
|
|
533
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
534
|
+
`);
|
|
535
|
+
const blank = lines.indexOf("");
|
|
536
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
537
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
538
|
+
const colon = synopses[0].indexOf(": ");
|
|
539
|
+
const inline = synopses[0].slice(colon + 2);
|
|
540
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
541
|
+
if (colon !== -1)
|
|
542
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
543
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
544
|
+
`)}`;
|
|
545
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
546
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
547
|
+
return [head, ...lead, ...rest].join(`
|
|
548
|
+
`);
|
|
549
|
+
}
|
|
550
|
+
function prose(line, colors) {
|
|
551
|
+
if (colors.cyan("x") === "x")
|
|
552
|
+
return line;
|
|
553
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
534
554
|
}
|
|
535
555
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
536
556
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -579,13 +599,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
579
599
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
580
600
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
581
601
|
}
|
|
582
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
602
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
583
603
|
var init_help = __esm(() => {
|
|
584
604
|
init_mode();
|
|
585
605
|
init_style();
|
|
586
606
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
587
607
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
588
608
|
FULL_STOP = /\.$/;
|
|
609
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
589
610
|
});
|
|
590
611
|
|
|
591
612
|
// ../kit/src/text.ts
|
|
@@ -836,7 +857,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
836
857
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
837
858
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
838
859
|
}
|
|
839
|
-
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
860
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
840
861
|
var init_args = __esm(() => {
|
|
841
862
|
init_format();
|
|
842
863
|
init_help();
|
|
@@ -844,14 +865,21 @@ var init_args = __esm(() => {
|
|
|
844
865
|
init_help();
|
|
845
866
|
init_input();
|
|
846
867
|
DASHES = /^-+/;
|
|
868
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
847
869
|
Exit = class Exit extends Error {
|
|
848
870
|
code;
|
|
849
871
|
hint;
|
|
872
|
+
[EXIT] = true;
|
|
850
873
|
constructor(message, code, hint) {
|
|
851
874
|
super(message);
|
|
852
875
|
this.code = code;
|
|
853
876
|
this.hint = hint;
|
|
854
877
|
}
|
|
878
|
+
static [Symbol.hasInstance](value) {
|
|
879
|
+
if (this !== Exit)
|
|
880
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
881
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
882
|
+
}
|
|
855
883
|
};
|
|
856
884
|
UsageError = class UsageError extends Exit {
|
|
857
885
|
constructor(message, hint) {
|
|
@@ -1596,10 +1624,10 @@ function holdSignals(cleanup) {
|
|
|
1596
1624
|
process11.on(signal, onSignal);
|
|
1597
1625
|
return held;
|
|
1598
1626
|
}
|
|
1599
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1627
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1600
1628
|
const chunks = [];
|
|
1601
1629
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
1602
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1630
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1603
1631
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
1604
1632
|
const timers = [];
|
|
1605
1633
|
const killGroup = (killing) => {
|
|
@@ -1913,7 +1941,9 @@ import process16 from "process";
|
|
|
1913
1941
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1914
1942
|
var ECHOED = /username|yes\/no/i;
|
|
1915
1943
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1916
|
-
function askpass(pause) {
|
|
1944
|
+
function askpass(pause = () => () => {
|
|
1945
|
+
return;
|
|
1946
|
+
}) {
|
|
1917
1947
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1918
1948
|
return;
|
|
1919
1949
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
@@ -2131,10 +2161,10 @@ function flagNames(argv) {
|
|
|
2131
2161
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
2132
2162
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
2133
2163
|
}
|
|
2134
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
2164
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
2135
2165
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
2136
2166
|
usageError = undefined;
|
|
2137
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
2167
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
2138
2168
|
}
|
|
2139
2169
|
function recordUsage(entry, env = process18.env) {
|
|
2140
2170
|
if (!usageRecorded(env))
|
|
@@ -2294,7 +2324,7 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
2294
2324
|
notifyEnd(name, code, performance.now() - started);
|
|
2295
2325
|
if (usage !== false) {
|
|
2296
2326
|
try {
|
|
2297
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
2327
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
2298
2328
|
} catch {}
|
|
2299
2329
|
}
|
|
2300
2330
|
return code;
|
|
@@ -2909,14 +2939,14 @@ function list(rows) {
|
|
|
2909
2939
|
// src/branch.ts
|
|
2910
2940
|
import { basename } from "path";
|
|
2911
2941
|
import process25 from "process";
|
|
2912
|
-
var usage2 = `gb [branch]
|
|
2942
|
+
var usage2 = `gb [branch]: picks a git branch and switches to it
|
|
2913
2943
|
gb -
|
|
2914
2944
|
gb -c <name>
|
|
2915
2945
|
gb -d <branch>
|
|
2916
2946
|
|
|
2917
|
-
Without a branch,
|
|
2918
|
-
\`gb <branch>\` switches without the picker,
|
|
2919
|
-
A branch checked out in another worktree cannot be switched to: gb prints that worktree's path
|
|
2947
|
+
Without a branch, on a terminal, picks one: the recently checked out first, then the other local ones, then the remote ones with no local branch yet (enter switches, ctrl-n creates, ctrl-d deletes a merged local branch with \`git branch -d\`, ctrl-r fetches and prunes); without a terminal it lists them.
|
|
2948
|
+
\`gb <branch>\` switches without the picker, \`gb -\` goes back to the previous branch, \`gb -c <name>\` creates one and switches to it, \`gb -d <branch>\` deletes a local one.
|
|
2949
|
+
A branch checked out in another worktree cannot be switched to: gb prints that worktree's path, since a command cannot change its shell's folder.`;
|
|
2920
2950
|
var EXITS = [[0, "it switched, created, deleted or listed"], ["git", "the code of the git command it ran, when that failed"], [1, "there is no branch by that name or nothing was picked"], [2, "outside a git repository or a usage error"]];
|
|
2921
2951
|
var options = {
|
|
2922
2952
|
create: { type: "boolean", short: "c", description: "create the branch named by the rest of the line and switch to it" },
|
|
@@ -3224,11 +3254,9 @@ async function git2(args, env) {
|
|
|
3224
3254
|
// src/gm.ts
|
|
3225
3255
|
var USAGE = `gm [branch]: merges the branch into the current one with git merge --no-edit, saying what came in
|
|
3226
3256
|
|
|
3227
|
-
Without a branch, on a terminal, picks one
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
Staged changes are refused, and so are unstaged ones in files the merge changes; other unstaged edits stay as they are, through a conflict and gm --abort too. The output names the outcome (fast-forward, merge commit or already up to date), the commits and the files that came in. On a conflict every conflicted file is listed with its conflict regions (the <<<<<<<, ======= and >>>>>>> lines and two lines around them, line numbers included) and the exit is 1.
|
|
3231
|
-
gm --dry-run <branch> says whether the merge would conflict and in which files, touching nothing (git merge-tree). gm --continue commits the merge once the markers are gone from the conflicted files, refusing while one remains; gm --abort gives the merge up.`;
|
|
3257
|
+
Without a branch, on a terminal, picks one with a preview of what merging it would do (enter merges, ctrl-s squashes); without a terminal it lists the branches with that verdict. A merge in progress is refused here: \`gm --continue\` or \`gm --abort\`.
|
|
3258
|
+
Staged changes are refused, and so are unstaged ones in files the merge changes; other unstaged edits stay as they are.
|
|
3259
|
+
On a conflict every conflicted file is listed with its conflict regions and the exit is 1.`;
|
|
3232
3260
|
var EXITS2 = [[0, "it merged, the branch was already merged, or --dry-run found no conflict"], [1, "a conflict, a dirty tree, an unknown branch, a refused step or git failed"], [2, "outside a git repository or a usage error"]];
|
|
3233
3261
|
var OPTIONS = {
|
|
3234
3262
|
abort: { type: "boolean", description: "give up the merge in progress", conflicts: ["continue", "dry-run"] },
|
package/dist/gp.js
CHANGED
|
@@ -530,7 +530,27 @@ var init_format = __esm(() => {
|
|
|
530
530
|
// ../kit/src/help.ts
|
|
531
531
|
import process8 from "process";
|
|
532
532
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
533
|
-
|
|
533
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
534
|
+
`);
|
|
535
|
+
const blank = lines.indexOf("");
|
|
536
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
537
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
538
|
+
const colon = synopses[0].indexOf(": ");
|
|
539
|
+
const inline = synopses[0].slice(colon + 2);
|
|
540
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
541
|
+
if (colon !== -1)
|
|
542
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
543
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
544
|
+
`)}`;
|
|
545
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
546
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
547
|
+
return [head, ...lead, ...rest].join(`
|
|
548
|
+
`);
|
|
549
|
+
}
|
|
550
|
+
function prose(line, colors) {
|
|
551
|
+
if (colors.cyan("x") === "x")
|
|
552
|
+
return line;
|
|
553
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
534
554
|
}
|
|
535
555
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
536
556
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -579,13 +599,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
579
599
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
580
600
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
581
601
|
}
|
|
582
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
602
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
583
603
|
var init_help = __esm(() => {
|
|
584
604
|
init_mode();
|
|
585
605
|
init_style();
|
|
586
606
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
587
607
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
588
608
|
FULL_STOP = /\.$/;
|
|
609
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
589
610
|
});
|
|
590
611
|
|
|
591
612
|
// ../kit/src/text.ts
|
|
@@ -836,7 +857,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
836
857
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
837
858
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
838
859
|
}
|
|
839
|
-
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
860
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
840
861
|
var init_args = __esm(() => {
|
|
841
862
|
init_format();
|
|
842
863
|
init_help();
|
|
@@ -844,14 +865,21 @@ var init_args = __esm(() => {
|
|
|
844
865
|
init_help();
|
|
845
866
|
init_input();
|
|
846
867
|
DASHES = /^-+/;
|
|
868
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
847
869
|
Exit = class Exit extends Error {
|
|
848
870
|
code;
|
|
849
871
|
hint;
|
|
872
|
+
[EXIT] = true;
|
|
850
873
|
constructor(message, code, hint) {
|
|
851
874
|
super(message);
|
|
852
875
|
this.code = code;
|
|
853
876
|
this.hint = hint;
|
|
854
877
|
}
|
|
878
|
+
static [Symbol.hasInstance](value) {
|
|
879
|
+
if (this !== Exit)
|
|
880
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
881
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
882
|
+
}
|
|
855
883
|
};
|
|
856
884
|
UsageError = class UsageError extends Exit {
|
|
857
885
|
constructor(message, hint) {
|
|
@@ -1595,10 +1623,10 @@ function holdSignals(cleanup) {
|
|
|
1595
1623
|
process11.on(signal, onSignal);
|
|
1596
1624
|
return held;
|
|
1597
1625
|
}
|
|
1598
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1626
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1599
1627
|
const chunks = [];
|
|
1600
1628
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
1601
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1629
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1602
1630
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
1603
1631
|
const timers = [];
|
|
1604
1632
|
const killGroup = (killing) => {
|
|
@@ -1912,7 +1940,9 @@ import process16 from "process";
|
|
|
1912
1940
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1913
1941
|
var ECHOED = /username|yes\/no/i;
|
|
1914
1942
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1915
|
-
function askpass(pause) {
|
|
1943
|
+
function askpass(pause = () => () => {
|
|
1944
|
+
return;
|
|
1945
|
+
}) {
|
|
1916
1946
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1917
1947
|
return;
|
|
1918
1948
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
@@ -2130,10 +2160,10 @@ function flagNames(argv) {
|
|
|
2130
2160
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
2131
2161
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
2132
2162
|
}
|
|
2133
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
2163
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
2134
2164
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
2135
2165
|
usageError = undefined;
|
|
2136
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
2166
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
2137
2167
|
}
|
|
2138
2168
|
function recordUsage(entry, env = process18.env) {
|
|
2139
2169
|
if (!usageRecorded(env))
|
|
@@ -2293,7 +2323,7 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
2293
2323
|
notifyEnd(name, code, performance.now() - started);
|
|
2294
2324
|
if (usage !== false) {
|
|
2295
2325
|
try {
|
|
2296
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
2326
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
2297
2327
|
} catch {}
|
|
2298
2328
|
}
|
|
2299
2329
|
return code;
|
|
@@ -2565,7 +2595,7 @@ async function dirsOf(positionals, all) {
|
|
|
2565
2595
|
}
|
|
2566
2596
|
|
|
2567
2597
|
// src/gp.ts
|
|
2568
|
-
var USAGE = `gp [dir]...: pushes the current branch of the repository, or of each dir
|
|
2598
|
+
var USAGE = `gp [dir]...: pushes the current branch of the repository, or of each dir, when it is ahead of its upstream or has none yet
|
|
2569
2599
|
|
|
2570
2600
|
--repos pushes every repository at and below the current one's toplevel, or below each dir given, the way gst --repos lists them. A detached HEAD, a branch with nothing to push and a repository with no remote are skipped, saying so; the pushes run one after another.
|
|
2571
2601
|
What follows -- goes to every git push as is (gp -- --tags, gp -- --force-with-lease), and a branch with nothing ahead is then pushed too.`;
|
package/dist/gst.js
CHANGED
|
@@ -530,7 +530,27 @@ var init_format = __esm(() => {
|
|
|
530
530
|
// ../kit/src/help.ts
|
|
531
531
|
import process8 from "process";
|
|
532
532
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
533
|
-
|
|
533
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
534
|
+
`);
|
|
535
|
+
const blank = lines.indexOf("");
|
|
536
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
537
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
538
|
+
const colon = synopses[0].indexOf(": ");
|
|
539
|
+
const inline = synopses[0].slice(colon + 2);
|
|
540
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
541
|
+
if (colon !== -1)
|
|
542
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
543
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
544
|
+
`)}`;
|
|
545
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
546
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
547
|
+
return [head, ...lead, ...rest].join(`
|
|
548
|
+
`);
|
|
549
|
+
}
|
|
550
|
+
function prose(line, colors) {
|
|
551
|
+
if (colors.cyan("x") === "x")
|
|
552
|
+
return line;
|
|
553
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
534
554
|
}
|
|
535
555
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
536
556
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -579,13 +599,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
579
599
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
580
600
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
581
601
|
}
|
|
582
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
602
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
583
603
|
var init_help = __esm(() => {
|
|
584
604
|
init_mode();
|
|
585
605
|
init_style();
|
|
586
606
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
587
607
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
588
608
|
FULL_STOP = /\.$/;
|
|
609
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
589
610
|
});
|
|
590
611
|
|
|
591
612
|
// ../kit/src/text.ts
|
|
@@ -836,7 +857,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
836
857
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
837
858
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
838
859
|
}
|
|
839
|
-
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
860
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
840
861
|
var init_args = __esm(() => {
|
|
841
862
|
init_format();
|
|
842
863
|
init_help();
|
|
@@ -844,14 +865,21 @@ var init_args = __esm(() => {
|
|
|
844
865
|
init_help();
|
|
845
866
|
init_input();
|
|
846
867
|
DASHES = /^-+/;
|
|
868
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
847
869
|
Exit = class Exit extends Error {
|
|
848
870
|
code;
|
|
849
871
|
hint;
|
|
872
|
+
[EXIT] = true;
|
|
850
873
|
constructor(message, code, hint) {
|
|
851
874
|
super(message);
|
|
852
875
|
this.code = code;
|
|
853
876
|
this.hint = hint;
|
|
854
877
|
}
|
|
878
|
+
static [Symbol.hasInstance](value) {
|
|
879
|
+
if (this !== Exit)
|
|
880
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
881
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
882
|
+
}
|
|
855
883
|
};
|
|
856
884
|
UsageError = class UsageError extends Exit {
|
|
857
885
|
constructor(message, hint) {
|
|
@@ -1595,10 +1623,10 @@ function holdSignals(cleanup) {
|
|
|
1595
1623
|
process11.on(signal, onSignal);
|
|
1596
1624
|
return held;
|
|
1597
1625
|
}
|
|
1598
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1626
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1599
1627
|
const chunks = [];
|
|
1600
1628
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
1601
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1629
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1602
1630
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
1603
1631
|
const timers = [];
|
|
1604
1632
|
const killGroup = (killing) => {
|
|
@@ -1912,7 +1940,9 @@ import process16 from "process";
|
|
|
1912
1940
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1913
1941
|
var ECHOED = /username|yes\/no/i;
|
|
1914
1942
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1915
|
-
function askpass(pause) {
|
|
1943
|
+
function askpass(pause = () => () => {
|
|
1944
|
+
return;
|
|
1945
|
+
}) {
|
|
1916
1946
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1917
1947
|
return;
|
|
1918
1948
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
@@ -2130,10 +2160,10 @@ function flagNames(argv) {
|
|
|
2130
2160
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
2131
2161
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
2132
2162
|
}
|
|
2133
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
2163
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
2134
2164
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
2135
2165
|
usageError = undefined;
|
|
2136
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
2166
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
2137
2167
|
}
|
|
2138
2168
|
function recordUsage(entry, env = process18.env) {
|
|
2139
2169
|
if (!usageRecorded(env))
|
|
@@ -2293,7 +2323,7 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
2293
2323
|
notifyEnd(name, code, performance.now() - started);
|
|
2294
2324
|
if (usage !== false) {
|
|
2295
2325
|
try {
|
|
2296
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
2326
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
2297
2327
|
} catch {}
|
|
2298
2328
|
}
|
|
2299
2329
|
return code;
|
package/dist/gu.js
CHANGED
|
@@ -530,7 +530,27 @@ var init_format = __esm(() => {
|
|
|
530
530
|
// ../kit/src/help.ts
|
|
531
531
|
import process8 from "process";
|
|
532
532
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
533
|
-
|
|
533
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
534
|
+
`);
|
|
535
|
+
const blank = lines.indexOf("");
|
|
536
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
537
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
538
|
+
const colon = synopses[0].indexOf(": ");
|
|
539
|
+
const inline = synopses[0].slice(colon + 2);
|
|
540
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
541
|
+
if (colon !== -1)
|
|
542
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
543
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
544
|
+
`)}`;
|
|
545
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
546
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
547
|
+
return [head, ...lead, ...rest].join(`
|
|
548
|
+
`);
|
|
549
|
+
}
|
|
550
|
+
function prose(line, colors) {
|
|
551
|
+
if (colors.cyan("x") === "x")
|
|
552
|
+
return line;
|
|
553
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
534
554
|
}
|
|
535
555
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
536
556
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -579,13 +599,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
579
599
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
580
600
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
581
601
|
}
|
|
582
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
602
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
583
603
|
var init_help = __esm(() => {
|
|
584
604
|
init_mode();
|
|
585
605
|
init_style();
|
|
586
606
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
587
607
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
588
608
|
FULL_STOP = /\.$/;
|
|
609
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
589
610
|
});
|
|
590
611
|
|
|
591
612
|
// ../kit/src/text.ts
|
|
@@ -836,7 +857,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
836
857
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
837
858
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
838
859
|
}
|
|
839
|
-
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
860
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
840
861
|
var init_args = __esm(() => {
|
|
841
862
|
init_format();
|
|
842
863
|
init_help();
|
|
@@ -844,14 +865,21 @@ var init_args = __esm(() => {
|
|
|
844
865
|
init_help();
|
|
845
866
|
init_input();
|
|
846
867
|
DASHES = /^-+/;
|
|
868
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
847
869
|
Exit = class Exit extends Error {
|
|
848
870
|
code;
|
|
849
871
|
hint;
|
|
872
|
+
[EXIT] = true;
|
|
850
873
|
constructor(message, code, hint) {
|
|
851
874
|
super(message);
|
|
852
875
|
this.code = code;
|
|
853
876
|
this.hint = hint;
|
|
854
877
|
}
|
|
878
|
+
static [Symbol.hasInstance](value) {
|
|
879
|
+
if (this !== Exit)
|
|
880
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
881
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
882
|
+
}
|
|
855
883
|
};
|
|
856
884
|
UsageError = class UsageError extends Exit {
|
|
857
885
|
constructor(message, hint) {
|
|
@@ -1597,10 +1625,10 @@ function holdSignals(cleanup) {
|
|
|
1597
1625
|
process11.on(signal, onSignal);
|
|
1598
1626
|
return held;
|
|
1599
1627
|
}
|
|
1600
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1628
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1601
1629
|
const chunks = [];
|
|
1602
1630
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
1603
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1631
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1604
1632
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
1605
1633
|
const timers = [];
|
|
1606
1634
|
const killGroup = (killing) => {
|
|
@@ -1914,7 +1942,9 @@ import process16 from "process";
|
|
|
1914
1942
|
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1915
1943
|
var ECHOED = /username|yes\/no/i;
|
|
1916
1944
|
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1917
|
-
function askpass(pause) {
|
|
1945
|
+
function askpass(pause = () => () => {
|
|
1946
|
+
return;
|
|
1947
|
+
}) {
|
|
1918
1948
|
if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
|
|
1919
1949
|
return;
|
|
1920
1950
|
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
@@ -2132,10 +2162,10 @@ function flagNames(argv) {
|
|
|
2132
2162
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
2133
2163
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
2134
2164
|
}
|
|
2135
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
2165
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
2136
2166
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
2137
2167
|
usageError = undefined;
|
|
2138
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
2168
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
2139
2169
|
}
|
|
2140
2170
|
function recordUsage(entry, env = process18.env) {
|
|
2141
2171
|
if (!usageRecorded(env))
|
|
@@ -2295,7 +2325,7 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
2295
2325
|
notifyEnd(name, code, performance.now() - started);
|
|
2296
2326
|
if (usage !== false) {
|
|
2297
2327
|
try {
|
|
2298
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
2328
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
2299
2329
|
} catch {}
|
|
2300
2330
|
}
|
|
2301
2331
|
return code;
|
|
@@ -2418,8 +2448,8 @@ async function git2(args, env) {
|
|
|
2418
2448
|
// src/gu.ts
|
|
2419
2449
|
var USAGE = `gu <path>...: undoes changes to the paths given, keeping what it takes away
|
|
2420
2450
|
|
|
2421
|
-
By default it discards the unstaged changes of the tracked paths, after saving them as a patch in the git folder (gu/<time>.patch) that \`git apply\` puts back. --staged unstages the paths
|
|
2422
|
-
|
|
2451
|
+
By default it discards the unstaged changes of the tracked paths, after saving them as a patch in the git folder (\`gu/<time>.patch\`) that \`git apply\` puts back. --staged unstages the paths. --commit undoes the last commit, its changes left staged, refusing one already on the upstream or a merge.
|
|
2452
|
+
Without a path it is a usage error, never "everything"; a path with no change is refused with nothing done.`;
|
|
2423
2453
|
var EXITS = [[0, "it undid what was asked"], [1, "a path has no change, the commit is pushed or git refused"], [2, "a usage error or outside a git repository"]];
|
|
2424
2454
|
var OPTIONS = {
|
|
2425
2455
|
staged: { type: "boolean", short: "s", description: "unstage the paths, the working tree untouched" },
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-git",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.2",
|
|
5
5
|
"description": "gst, gc, gb, gp, gf, gm, gcl, gd and gu: a repository's state in one call, a commit of exactly the paths given, its message checked before anything is staged, a branch picked, nested repositories pushed or fetched, a branch merged with its conflicts listed, a clone into the workspace, the changes per file and an undo that keeps what it takes away.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
"gu": "$npm_execpath src/gu.ts"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@kaynooo/cli-kit": "0.
|
|
59
|
+
"@kaynooo/cli-kit": "0.45.1"
|
|
60
60
|
}
|
|
61
61
|
}
|