@kaynooo/cli-edit 0.11.0 → 0.11.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/dist/cli.js +81 -2
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -546,7 +546,7 @@ class Completing {
|
|
|
546
546
|
}
|
|
547
547
|
var completion = { active: false };
|
|
548
548
|
var OUTPUT_OPTIONS = {
|
|
549
|
-
color: { type: "string", description: "auto (on a terminal alone
|
|
549
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
550
550
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
551
551
|
};
|
|
552
552
|
function applyOutput(color, plain, env = process10.env) {
|
|
@@ -842,6 +842,66 @@ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs
|
|
|
842
842
|
import { dirname as dirname3, join as join5 } from "path";
|
|
843
843
|
import process15 from "process";
|
|
844
844
|
|
|
845
|
+
// ../kit/src/completions.ts
|
|
846
|
+
var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
847
|
+
var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
|
|
848
|
+
set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
|
|
849
|
+
set -l current (commandline -ct)
|
|
850
|
+
for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
|
|
851
|
+
if test "$line" = __files__
|
|
852
|
+
__fish_complete_path $current
|
|
853
|
+
else
|
|
854
|
+
echo $line
|
|
855
|
+
end
|
|
856
|
+
end
|
|
857
|
+
end`;
|
|
858
|
+
var BASH_FUNCTION = `__kaynooo_cli_complete() {
|
|
859
|
+
local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
|
|
860
|
+
local -a lines
|
|
861
|
+
COMPREPLY=()
|
|
862
|
+
lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
|
|
863
|
+
for line in "\${lines[@]}"; do
|
|
864
|
+
if [[ $line == __files__ ]]; then
|
|
865
|
+
COMPREPLY+=($(compgen -f -- "$cur"))
|
|
866
|
+
else
|
|
867
|
+
words+="\${line%%$'\\t'*}"$'\\n'
|
|
868
|
+
fi
|
|
869
|
+
done
|
|
870
|
+
COMPREPLY+=($(compgen -W "$words" -- "$cur"))
|
|
871
|
+
}`;
|
|
872
|
+
var ZSH_FUNCTION = `__kaynooo_cli_complete() {
|
|
873
|
+
local line
|
|
874
|
+
local -a described plain
|
|
875
|
+
for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
|
|
876
|
+
if [[ $line == __files__ ]]; then
|
|
877
|
+
_files
|
|
878
|
+
elif [[ $line == *$'\\t'* ]]; then
|
|
879
|
+
described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
|
|
880
|
+
else
|
|
881
|
+
plain+=("$line")
|
|
882
|
+
fi
|
|
883
|
+
done
|
|
884
|
+
(( \${#described} )) && _describe -V value described
|
|
885
|
+
(( \${#plain} )) && compadd -- "\${plain[@]}"
|
|
886
|
+
return 0
|
|
887
|
+
}`;
|
|
888
|
+
function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
|
|
889
|
+
if (shell === "fish")
|
|
890
|
+
return `${header}
|
|
891
|
+
${FISH_FUNCTION}
|
|
892
|
+
${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
|
|
893
|
+
`).join("")}`;
|
|
894
|
+
if (shell === "bash")
|
|
895
|
+
return `${header}
|
|
896
|
+
${BASH_FUNCTION}
|
|
897
|
+
complete -F __kaynooo_cli_complete ${bins.join(" ")}
|
|
898
|
+
`;
|
|
899
|
+
return `${header}
|
|
900
|
+
${ZSH_FUNCTION}
|
|
901
|
+
compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
902
|
+
`;
|
|
903
|
+
}
|
|
904
|
+
|
|
845
905
|
// ../kit/src/notify.ts
|
|
846
906
|
import process13 from "process";
|
|
847
907
|
var NOTIFY_AFTER_MS = 1e4;
|
|
@@ -915,7 +975,11 @@ var LEVEL_OPTIONS = {
|
|
|
915
975
|
...OUTPUT_OPTIONS,
|
|
916
976
|
help: { type: "boolean", short: "h", description: "show this help" }
|
|
917
977
|
};
|
|
918
|
-
var TOP_OPTIONS = {
|
|
978
|
+
var TOP_OPTIONS = {
|
|
979
|
+
...LEVEL_OPTIONS,
|
|
980
|
+
version: { type: "boolean", short: "v", description: "print the version" },
|
|
981
|
+
completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
|
|
982
|
+
};
|
|
919
983
|
function printError(prefix, message, hint, cause) {
|
|
920
984
|
const colors = paint(process15.stderr);
|
|
921
985
|
const styled = takesControlCodes(process15.stderr);
|
|
@@ -995,6 +1059,19 @@ async function leafCandidates(run, words) {
|
|
|
995
1059
|
const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
|
|
996
1060
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
997
1061
|
}
|
|
1062
|
+
var COMPLETIONS = "--completions";
|
|
1063
|
+
function flagValue([flag = "", ...rest]) {
|
|
1064
|
+
return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
|
|
1065
|
+
}
|
|
1066
|
+
function printCompletionScript(name, args) {
|
|
1067
|
+
const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
|
|
1068
|
+
if (shell === undefined || args.length !== 1) {
|
|
1069
|
+
printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
|
|
1070
|
+
return 2;
|
|
1071
|
+
}
|
|
1072
|
+
console.log(completionScript(shell, [name]).trimEnd());
|
|
1073
|
+
return 0;
|
|
1074
|
+
}
|
|
998
1075
|
async function printCandidates(found) {
|
|
999
1076
|
for (const line of await found)
|
|
1000
1077
|
console.log(line);
|
|
@@ -1018,6 +1095,8 @@ function packageVersion(entry = Bun.main) {
|
|
|
1018
1095
|
async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
|
|
1019
1096
|
if (argv[0] === COMPLETE)
|
|
1020
1097
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1098
|
+
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
1099
|
+
return printCompletionScript(name, flagValue(argv));
|
|
1021
1100
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
1022
1101
|
console.log(version ?? packageVersion());
|
|
1023
1102
|
return 0;
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-edit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.2",
|
|
5
5
|
"description": "sub: text replaced in files for Claude Code, written only when every replacement matches as often as expected.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"homepage": "https://
|
|
8
|
+
"homepage": "https://github.com/Kayno0o/cli/tree/main/packages/edit#readme",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://
|
|
11
|
+
"url": "git+https://github.com/Kayno0o/cli.git",
|
|
12
12
|
"directory": "packages/edit"
|
|
13
13
|
},
|
|
14
|
-
"bugs": "https://
|
|
14
|
+
"bugs": "https://github.com/Kayno0o/cli/issues",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"claude-code",
|
|
17
17
|
"cli",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"@kaynooo/utils": "3.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@kaynooo/cli-kit": "0.
|
|
42
|
+
"@kaynooo/cli-kit": "0.41.0"
|
|
43
43
|
}
|
|
44
44
|
}
|