cluttry 1.0.1 → 1.0.3
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/commands/open.d.ts +1 -0
- package/dist/commands/open.d.ts.map +1 -1
- package/dist/commands/open.js +8 -2
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/shell.d.ts +11 -0
- package/dist/commands/shell.d.ts.map +1 -0
- package/dist/commands/shell.js +89 -0
- package/dist/commands/shell.js.map +1 -0
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/open.ts +10 -2
- package/src/commands/shell.ts +99 -0
- package/src/index.ts +12 -1
package/dist/commands/open.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../src/commands/open.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,UAAU,WAAW;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../src/commands/open.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,UAAU,WAAW;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAyDpF"}
|
package/dist/commands/open.js
CHANGED
|
@@ -30,6 +30,11 @@ export async function open(branchOrPath, options) {
|
|
|
30
30
|
process.exit(1);
|
|
31
31
|
}
|
|
32
32
|
const { path: wtPath, branch } = resolved;
|
|
33
|
+
// If --path-only, just print the path (for scripting)
|
|
34
|
+
if (options.pathOnly) {
|
|
35
|
+
console.log(wtPath);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
33
38
|
// If --cmd is provided, run it
|
|
34
39
|
if (options.cmd) {
|
|
35
40
|
out.log(`Running in ${out.fmt.path(wtPath)}:`);
|
|
@@ -46,7 +51,8 @@ export async function open(branchOrPath, options) {
|
|
|
46
51
|
out.log(` ${out.fmt.cyan(`cd "${wtPath}"`)}`);
|
|
47
52
|
// For shell integration hint
|
|
48
53
|
out.newline();
|
|
49
|
-
out.log(out.fmt.dim('Tip:
|
|
50
|
-
out.log(out.fmt.dim(
|
|
54
|
+
out.log(out.fmt.dim('Tip: Add this to your shell profile for easy navigation:'));
|
|
55
|
+
out.log(out.fmt.dim(' crycd() { cd "$(cry open "$1" --path-only)"; }'));
|
|
56
|
+
out.log(out.fmt.dim(' # Then use: crycd feature/my-branch'));
|
|
51
57
|
}
|
|
52
58
|
//# sourceMappingURL=open.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/commands/open.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,WAAW,EACX,aAAa,EACb,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/commands/open.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,WAAW,EACX,aAAa,EACb,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAOxC,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,YAAoB,EAAE,OAAoB;IACnE,+BAA+B;IAC/B,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QACjB,GAAG,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;QAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAA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
export declare function shell(options: ShellOptions): Promise<void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/commands/shell.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiEH,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBhE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cry shell command
|
|
3
|
+
*
|
|
4
|
+
* Output shell integration code for easy directory navigation.
|
|
5
|
+
*/
|
|
6
|
+
import * as out from '../lib/output.js';
|
|
7
|
+
const SHELL_FUNCTIONS = {
|
|
8
|
+
bash: `# cry shell integration (add to ~/.bashrc)
|
|
9
|
+
crycd() {
|
|
10
|
+
local target
|
|
11
|
+
target="$(cry open "$1" --path-only 2>/dev/null)"
|
|
12
|
+
if [ -n "$target" ]; then
|
|
13
|
+
cd "$target"
|
|
14
|
+
else
|
|
15
|
+
echo "Worktree not found: $1" >&2
|
|
16
|
+
return 1
|
|
17
|
+
fi
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# Auto-completion for crycd
|
|
21
|
+
_crycd_completions() {
|
|
22
|
+
local branches
|
|
23
|
+
branches=$(cry list --json 2>/dev/null | grep -o '"branch":"[^"]*"' | cut -d'"' -f4)
|
|
24
|
+
COMPREPLY=($(compgen -W "$branches" -- "\${COMP_WORDS[COMP_CWORD]}"))
|
|
25
|
+
}
|
|
26
|
+
complete -F _crycd_completions crycd
|
|
27
|
+
`,
|
|
28
|
+
zsh: `# cry shell integration (add to ~/.zshrc)
|
|
29
|
+
crycd() {
|
|
30
|
+
local target
|
|
31
|
+
target="$(cry open "$1" --path-only 2>/dev/null)"
|
|
32
|
+
if [[ -n "$target" ]]; then
|
|
33
|
+
cd "$target"
|
|
34
|
+
else
|
|
35
|
+
echo "Worktree not found: $1" >&2
|
|
36
|
+
return 1
|
|
37
|
+
fi
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Auto-completion for crycd
|
|
41
|
+
_crycd() {
|
|
42
|
+
local branches
|
|
43
|
+
branches=(\${(f)"$(cry list --json 2>/dev/null | grep -o '"branch":"[^"]*"' | cut -d'"' -f4)"})
|
|
44
|
+
_describe 'branch' branches
|
|
45
|
+
}
|
|
46
|
+
compdef _crycd crycd
|
|
47
|
+
`,
|
|
48
|
+
fish: `# cry shell integration (add to ~/.config/fish/config.fish)
|
|
49
|
+
function crycd
|
|
50
|
+
set -l target (cry open $argv[1] --path-only 2>/dev/null)
|
|
51
|
+
if test -n "$target"
|
|
52
|
+
cd $target
|
|
53
|
+
else
|
|
54
|
+
echo "Worktree not found: $argv[1]" >&2
|
|
55
|
+
return 1
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Auto-completion for crycd
|
|
60
|
+
complete -c crycd -f -a "(cry list --json 2>/dev/null | grep -o '\"branch\":\"[^\"]*\"' | cut -d'\"' -f4)"
|
|
61
|
+
`,
|
|
62
|
+
};
|
|
63
|
+
export async function shell(options) {
|
|
64
|
+
const shellEnv = process.env.SHELL ?? '';
|
|
65
|
+
let detectedShell = 'bash';
|
|
66
|
+
if (options.shell) {
|
|
67
|
+
if (options.shell === 'fish' || options.shell === 'zsh' || options.shell === 'bash') {
|
|
68
|
+
detectedShell = options.shell;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
out.error(`Unsupported shell: ${options.shell}`);
|
|
72
|
+
out.info('Supported shells: bash, zsh, fish');
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (shellEnv.includes('zsh')) {
|
|
77
|
+
detectedShell = 'zsh';
|
|
78
|
+
}
|
|
79
|
+
else if (shellEnv.includes('fish')) {
|
|
80
|
+
detectedShell = 'fish';
|
|
81
|
+
}
|
|
82
|
+
const script = SHELL_FUNCTIONS[detectedShell];
|
|
83
|
+
out.log(out.fmt.dim(`# Shell integration for ${detectedShell}`));
|
|
84
|
+
out.log(out.fmt.dim('# Copy and paste into your shell config, or run:'));
|
|
85
|
+
out.log(out.fmt.dim(`# cry shell >> ~/.${detectedShell === 'fish' ? 'config/fish/config.fish' : detectedShell + 'rc'}`));
|
|
86
|
+
out.newline();
|
|
87
|
+
console.log(script);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/commands/shell.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAIxC,MAAM,eAAe,GAA8B;IACjD,IAAI,EAAE;;;;;;;;;;;;;;;;;;;CAmBP;IAEC,GAAG,EAAE;;;;;;;;;;;;;;;;;;;CAmBN;IAEC,IAAI,EAAE;;;;;;;;;;;;;CAaP;CACA,CAAC;AAMF,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAqB;IAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;IACzC,IAAI,aAAa,GAAc,MAAM,CAAC;IAEtC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,IAAI,OAAO,CAAC,KAAK,KAAK,MAAM,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK,IAAI,OAAO,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;YACpF,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,KAAK,CAAC,sBAAsB,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;YACjD,GAAG,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;YAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;SAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACpC,aAAa,GAAG,KAAK,CAAC;IACxB,CAAC;SAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACrC,aAAa,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,MAAM,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IAE9C,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,2BAA2B,aAAa,EAAE,CAAC,CAAC,CAAC;IACjE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC,CAAC;IACzE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,uBAAuB,aAAa,KAAK,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,aAAa,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3H,GAAG,CAAC,OAAO,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { open } from './commands/open.js';
|
|
|
12
12
|
import { rm } from './commands/rm.js';
|
|
13
13
|
import { prune } from './commands/prune.js';
|
|
14
14
|
import { doctor } from './commands/doctor.js';
|
|
15
|
+
import { shell } from './commands/shell.js';
|
|
15
16
|
const program = new Command();
|
|
16
17
|
program
|
|
17
18
|
.name('cry')
|
|
@@ -64,8 +65,9 @@ program
|
|
|
64
65
|
.command('open <branch-or-path>')
|
|
65
66
|
.description('Open or navigate to a worktree by branch name or path')
|
|
66
67
|
.option('-c, --cmd <cmd>', 'Command to execute in the worktree directory')
|
|
68
|
+
.option('-p, --path-only', 'Only print the path (for scripting)')
|
|
67
69
|
.action(async (branchOrPath, options) => {
|
|
68
|
-
await open(branchOrPath, { cmd: options.cmd });
|
|
70
|
+
await open(branchOrPath, { cmd: options.cmd, pathOnly: options.pathOnly });
|
|
69
71
|
});
|
|
70
72
|
// cry rm <branch-or-path>
|
|
71
73
|
program
|
|
@@ -96,6 +98,14 @@ program
|
|
|
96
98
|
.action(async () => {
|
|
97
99
|
await doctor();
|
|
98
100
|
});
|
|
101
|
+
// cry shell
|
|
102
|
+
program
|
|
103
|
+
.command('shell')
|
|
104
|
+
.description('Output shell integration code for crycd navigation function')
|
|
105
|
+
.option('-s, --shell <shell>', 'Shell type: bash, zsh, or fish (auto-detected)')
|
|
106
|
+
.action(async (options) => {
|
|
107
|
+
await shell({ shell: options.shell });
|
|
108
|
+
});
|
|
99
109
|
// Parse and execute
|
|
100
110
|
program.parse();
|
|
101
111
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI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C;AAEL,oBAAoB;AACpB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/commands/open.ts
CHANGED
|
@@ -15,6 +15,7 @@ import * as out from '../lib/output.js';
|
|
|
15
15
|
|
|
16
16
|
interface OpenOptions {
|
|
17
17
|
cmd?: string;
|
|
18
|
+
pathOnly?: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export async function open(branchOrPath: string, options: OpenOptions): Promise<void> {
|
|
@@ -47,6 +48,12 @@ export async function open(branchOrPath: string, options: OpenOptions): Promise<
|
|
|
47
48
|
|
|
48
49
|
const { path: wtPath, branch } = resolved;
|
|
49
50
|
|
|
51
|
+
// If --path-only, just print the path (for scripting)
|
|
52
|
+
if (options.pathOnly) {
|
|
53
|
+
console.log(wtPath);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
50
57
|
// If --cmd is provided, run it
|
|
51
58
|
if (options.cmd) {
|
|
52
59
|
out.log(`Running in ${out.fmt.path(wtPath)}:`);
|
|
@@ -65,6 +72,7 @@ export async function open(branchOrPath: string, options: OpenOptions): Promise<
|
|
|
65
72
|
|
|
66
73
|
// For shell integration hint
|
|
67
74
|
out.newline();
|
|
68
|
-
out.log(out.fmt.dim('Tip:
|
|
69
|
-
out.log(out.fmt.dim(
|
|
75
|
+
out.log(out.fmt.dim('Tip: Add this to your shell profile for easy navigation:'));
|
|
76
|
+
out.log(out.fmt.dim(' crycd() { cd "$(cry open "$1" --path-only)"; }'));
|
|
77
|
+
out.log(out.fmt.dim(' # Then use: crycd feature/my-branch'));
|
|
70
78
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cry shell command
|
|
3
|
+
*
|
|
4
|
+
* Output shell integration code for easy directory navigation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as out from '../lib/output.js';
|
|
8
|
+
|
|
9
|
+
type ShellType = 'bash' | 'zsh' | 'fish';
|
|
10
|
+
|
|
11
|
+
const SHELL_FUNCTIONS: Record<ShellType, string> = {
|
|
12
|
+
bash: `# cry shell integration (add to ~/.bashrc)
|
|
13
|
+
crycd() {
|
|
14
|
+
local target
|
|
15
|
+
target="$(cry open "$1" --path-only 2>/dev/null)"
|
|
16
|
+
if [ -n "$target" ]; then
|
|
17
|
+
cd "$target"
|
|
18
|
+
else
|
|
19
|
+
echo "Worktree not found: $1" >&2
|
|
20
|
+
return 1
|
|
21
|
+
fi
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# Auto-completion for crycd
|
|
25
|
+
_crycd_completions() {
|
|
26
|
+
local branches
|
|
27
|
+
branches=$(cry list --json 2>/dev/null | grep -o '"branch":"[^"]*"' | cut -d'"' -f4)
|
|
28
|
+
COMPREPLY=($(compgen -W "$branches" -- "\${COMP_WORDS[COMP_CWORD]}"))
|
|
29
|
+
}
|
|
30
|
+
complete -F _crycd_completions crycd
|
|
31
|
+
`,
|
|
32
|
+
|
|
33
|
+
zsh: `# cry shell integration (add to ~/.zshrc)
|
|
34
|
+
crycd() {
|
|
35
|
+
local target
|
|
36
|
+
target="$(cry open "$1" --path-only 2>/dev/null)"
|
|
37
|
+
if [[ -n "$target" ]]; then
|
|
38
|
+
cd "$target"
|
|
39
|
+
else
|
|
40
|
+
echo "Worktree not found: $1" >&2
|
|
41
|
+
return 1
|
|
42
|
+
fi
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# Auto-completion for crycd
|
|
46
|
+
_crycd() {
|
|
47
|
+
local branches
|
|
48
|
+
branches=(\${(f)"$(cry list --json 2>/dev/null | grep -o '"branch":"[^"]*"' | cut -d'"' -f4)"})
|
|
49
|
+
_describe 'branch' branches
|
|
50
|
+
}
|
|
51
|
+
compdef _crycd crycd
|
|
52
|
+
`,
|
|
53
|
+
|
|
54
|
+
fish: `# cry shell integration (add to ~/.config/fish/config.fish)
|
|
55
|
+
function crycd
|
|
56
|
+
set -l target (cry open $argv[1] --path-only 2>/dev/null)
|
|
57
|
+
if test -n "$target"
|
|
58
|
+
cd $target
|
|
59
|
+
else
|
|
60
|
+
echo "Worktree not found: $argv[1]" >&2
|
|
61
|
+
return 1
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Auto-completion for crycd
|
|
66
|
+
complete -c crycd -f -a "(cry list --json 2>/dev/null | grep -o '\"branch\":\"[^\"]*\"' | cut -d'\"' -f4)"
|
|
67
|
+
`,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
interface ShellOptions {
|
|
71
|
+
shell?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function shell(options: ShellOptions): Promise<void> {
|
|
75
|
+
const shellEnv = process.env.SHELL ?? '';
|
|
76
|
+
let detectedShell: ShellType = 'bash';
|
|
77
|
+
|
|
78
|
+
if (options.shell) {
|
|
79
|
+
if (options.shell === 'fish' || options.shell === 'zsh' || options.shell === 'bash') {
|
|
80
|
+
detectedShell = options.shell;
|
|
81
|
+
} else {
|
|
82
|
+
out.error(`Unsupported shell: ${options.shell}`);
|
|
83
|
+
out.info('Supported shells: bash, zsh, fish');
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
} else if (shellEnv.includes('zsh')) {
|
|
87
|
+
detectedShell = 'zsh';
|
|
88
|
+
} else if (shellEnv.includes('fish')) {
|
|
89
|
+
detectedShell = 'fish';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const script = SHELL_FUNCTIONS[detectedShell];
|
|
93
|
+
|
|
94
|
+
out.log(out.fmt.dim(`# Shell integration for ${detectedShell}`));
|
|
95
|
+
out.log(out.fmt.dim('# Copy and paste into your shell config, or run:'));
|
|
96
|
+
out.log(out.fmt.dim(`# cry shell >> ~/.${detectedShell === 'fish' ? 'config/fish/config.fish' : detectedShell + 'rc'}`));
|
|
97
|
+
out.newline();
|
|
98
|
+
console.log(script);
|
|
99
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { open } from './commands/open.js';
|
|
|
13
13
|
import { rm } from './commands/rm.js';
|
|
14
14
|
import { prune } from './commands/prune.js';
|
|
15
15
|
import { doctor } from './commands/doctor.js';
|
|
16
|
+
import { shell } from './commands/shell.js';
|
|
16
17
|
import type { SecretMode } from './lib/types.js';
|
|
17
18
|
|
|
18
19
|
const program = new Command();
|
|
@@ -72,8 +73,9 @@ program
|
|
|
72
73
|
.command('open <branch-or-path>')
|
|
73
74
|
.description('Open or navigate to a worktree by branch name or path')
|
|
74
75
|
.option('-c, --cmd <cmd>', 'Command to execute in the worktree directory')
|
|
76
|
+
.option('-p, --path-only', 'Only print the path (for scripting)')
|
|
75
77
|
.action(async (branchOrPath: string, options) => {
|
|
76
|
-
await open(branchOrPath, { cmd: options.cmd });
|
|
78
|
+
await open(branchOrPath, { cmd: options.cmd, pathOnly: options.pathOnly });
|
|
77
79
|
});
|
|
78
80
|
|
|
79
81
|
// cry rm <branch-or-path>
|
|
@@ -108,5 +110,14 @@ program
|
|
|
108
110
|
await doctor();
|
|
109
111
|
});
|
|
110
112
|
|
|
113
|
+
// cry shell
|
|
114
|
+
program
|
|
115
|
+
.command('shell')
|
|
116
|
+
.description('Output shell integration code for crycd navigation function')
|
|
117
|
+
.option('-s, --shell <shell>', 'Shell type: bash, zsh, or fish (auto-detected)')
|
|
118
|
+
.action(async (options) => {
|
|
119
|
+
await shell({ shell: options.shell });
|
|
120
|
+
});
|
|
121
|
+
|
|
111
122
|
// Parse and execute
|
|
112
123
|
program.parse();
|