claude-yes 1.14.1 → 1.15.0

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/cli.ts CHANGED
@@ -1,47 +1,57 @@
1
1
  #!/usr/bin/env node
2
- import ms from "enhanced-ms";
3
- import minimist from "minimist";
4
- import claudeYes from ".";
2
+ import ms from 'enhanced-ms';
3
+ import yargs from 'yargs';
4
+ import { hideBin } from 'yargs/helpers';
5
+ import claudeYes from '.';
5
6
 
6
7
  // cli entry point
7
- const args = minimist(process.argv.slice(2), {
8
- string: ['exit-on-idle'],
9
- boolean: ['continue-on-crash'],
10
- // boolean: ['exit-on-idle'],
11
- default: {
12
- 'exit-on-idle': '60s',
13
- 'continue-on-crash': true,
14
- }
15
- });
16
-
17
- const { 'exit-on-idle': exitOnIdleArg, 'continue-on-crash': continueOnCrashArg, ...rest } = args;
18
- const claudeArgs = Object.entries(rest).flatMap(([key, value]) => {
19
- if (key === '_') return value as string[];
20
- if (typeof value === 'boolean') return value ? [`--${key}`] : [];
21
- return [`--${key}`, String(value)];
22
- });
8
+ const argv = yargs(hideBin(process.argv))
9
+ .usage('Usage: $0 [options] [claude args]')
10
+ .option('exit-on-idle', {
11
+ type: 'string',
12
+ default: '60s',
13
+ description: 'Exit after being idle for specified duration',
14
+ })
15
+ .option('continue-on-crash', {
16
+ type: 'boolean',
17
+ default: true,
18
+ description: 'Continue running even if Claude crashes',
19
+ })
20
+ .option('log-file', {
21
+ type: 'string',
22
+ description: 'Path to log file for output logging',
23
+ })
24
+ .option('verbose', {
25
+ type: 'boolean',
26
+ default: false,
27
+ description: 'Enable verbose logging',
28
+ })
29
+ .parserConfiguration({
30
+ 'unknown-options-as-args': true,
31
+ 'halt-at-non-option': true,
32
+ })
33
+ .parseSync();
23
34
 
35
+ const {
36
+ exitOnIdle: exitOnIdleArg,
37
+ continueOnCrash: continueOnCrashArg,
38
+ logFile,
39
+ ...rest
40
+ } = argv;
24
41
 
25
- let exitOnIdle: boolean | number | undefined;
26
- if (typeof exitOnIdleArg === 'string') {
27
- if (exitOnIdleArg === '') {
28
- exitOnIdle = true; // default timeout will be used
29
- } else {
30
- exitOnIdle = ms(exitOnIdleArg); // parse duration string like "5s", "30s", "1m"
31
- }
32
- } else {
33
- exitOnIdle = undefined;
34
- }
42
+ const claudeArgs = argv._.map((e) => String(e));
43
+ const exitOnIdle = argv.exitOnIdle != null ? ms(argv.exitOnIdle) : undefined;
35
44
 
36
-
37
- // console.debug('Parsed args:', {
38
- // exitOnIdle,
39
- // continueOnCrash: continueOnCrashArg,
40
- // claudeArgs,
41
- // });
42
-
43
- await claudeYes({
45
+ argv.verbose &&
46
+ console.debug('[claude-yes] Parsed args:', {
44
47
  exitOnIdle,
45
- claudeArgs,
46
48
  continueOnCrash: continueOnCrashArg,
47
- });
49
+ claudeArgs,
50
+ });
51
+
52
+ await claudeYes({
53
+ exitOnIdle,
54
+ claudeArgs,
55
+ continueOnCrash: continueOnCrashArg,
56
+ logFile,
57
+ });