tt-help-cli-ycl 1.3.30 → 1.3.32

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/src/lib/args.js CHANGED
@@ -1,7 +1,7 @@
1
- import { readFileSync } from 'fs';
2
- import { server as defaultServer } from './constants.js';
1
+ import { readFileSync } from "fs";
2
+ import { server as defaultServer } from "./constants.js";
3
3
 
4
- const PRESETS = ['fast', 'normal', 'slow', 'stealth'];
4
+ const PRESETS = ["fast", "normal", "slow", "stealth"];
5
5
 
6
6
  function parseScrapeArgs(args) {
7
7
  let scrapeUrl = null;
@@ -17,11 +17,11 @@ function parseScrapeArgs(args) {
17
17
 
18
18
  for (let i = 0; i < args.length; i++) {
19
19
  const arg = args[i];
20
- if (arg === '-o' || arg === '--output') {
20
+ if (arg === "-o" || arg === "--output") {
21
21
  outputFile = args[++i];
22
- } else if (arg === '--switch-delay') {
22
+ } else if (arg === "--switch-delay") {
23
23
  scrapeSwitchDelay = parseInt(args[++i]) || null;
24
- } else if (arg === '--comment-delay') {
24
+ } else if (arg === "--comment-delay") {
25
25
  scrapeCommentDelay = parseInt(args[++i]) || null;
26
26
  } else {
27
27
  positional.push(arg);
@@ -44,7 +44,7 @@ function parseScrapeArgs(args) {
44
44
  }
45
45
 
46
46
  return {
47
- subcommand: 'scrape',
47
+ subcommand: "scrape",
48
48
  scrapeUrl,
49
49
  scrapePreset,
50
50
  scrapeMaxVideos,
@@ -54,7 +54,7 @@ function parseScrapeArgs(args) {
54
54
  scrapeCommentDelay,
55
55
  outputFile,
56
56
  urls: [],
57
- outputFormat: 'json',
57
+ outputFormat: "json",
58
58
  exploreCount: 0,
59
59
  showConfig: false,
60
60
  showHelp: false,
@@ -71,7 +71,7 @@ function parseAutoArgs(args) {
71
71
  let autoScrapeDepth = 50;
72
72
  let autoMaxComments = 200;
73
73
  let autoMaxGuess = 10;
74
- let autoPreset = 'fast';
74
+ let autoPreset = "fast";
75
75
  let autoSwitchDelay = null;
76
76
  let autoCommentDelay = null;
77
77
  let serverUrl = defaultServer;
@@ -80,21 +80,21 @@ function parseAutoArgs(args) {
80
80
  let autoMaxFollowers = 200;
81
81
 
82
82
  const positional = [];
83
- const PRESETS = ['fast', 'normal', 'slow', 'stealth'];
83
+ const PRESETS = ["fast", "normal", "slow", "stealth"];
84
84
 
85
85
  for (let i = 0; i < args.length; i++) {
86
86
  const arg = args[i];
87
- if (arg === '--server') {
87
+ if (arg === "--server") {
88
88
  serverUrl = args[++i];
89
- } else if (arg === '--switch-delay') {
89
+ } else if (arg === "--switch-delay") {
90
90
  autoSwitchDelay = parseInt(args[++i]) || null;
91
- } else if (arg === '--comment-delay') {
91
+ } else if (arg === "--comment-delay") {
92
92
  autoCommentDelay = parseInt(args[++i]) || null;
93
- } else if (arg === '--enable-follow') {
93
+ } else if (arg === "--enable-follow") {
94
94
  autoEnableFollow = true;
95
- } else if (arg === '--max-following') {
95
+ } else if (arg === "--max-following") {
96
96
  autoMaxFollowing = parseInt(args[++i]) || 200;
97
- } else if (arg === '--max-followers') {
97
+ } else if (arg === "--max-followers") {
98
98
  autoMaxFollowers = parseInt(args[++i]) || 200;
99
99
  } else {
100
100
  positional.push(arg);
@@ -104,8 +104,12 @@ function parseAutoArgs(args) {
104
104
  // 收集用户名(非 preset、非数字的都是用户名)
105
105
  const usernames = [];
106
106
  let j = 0;
107
- while (j < positional.length && !PRESETS.includes(positional[j]?.toLowerCase()) && isNaN(positional[j])) {
108
- usernames.push(positional[j].replace('@', ''));
107
+ while (
108
+ j < positional.length &&
109
+ !PRESETS.includes(positional[j]?.toLowerCase()) &&
110
+ isNaN(positional[j])
111
+ ) {
112
+ usernames.push(positional[j].replace("@", ""));
109
113
  j++;
110
114
  }
111
115
 
@@ -113,19 +117,26 @@ function parseAutoArgs(args) {
113
117
  if (j < positional.length && PRESETS.includes(positional[j].toLowerCase())) {
114
118
  autoPreset = positional[j].toLowerCase();
115
119
  j++;
116
- autoCollectMax = parseInt(positional[j]) || 1; j++;
117
- autoScrapeDepth = parseInt(positional[j]) || 50; j++;
118
- autoMaxComments = parseInt(positional[j]) || 200; j++;
119
- autoMaxGuess = parseInt(positional[j]) || 10; j++;
120
+ autoCollectMax = parseInt(positional[j]) || 1;
121
+ j++;
122
+ autoScrapeDepth = parseInt(positional[j]) || 50;
123
+ j++;
124
+ autoMaxComments = parseInt(positional[j]) || 200;
125
+ j++;
126
+ autoMaxGuess = parseInt(positional[j]) || 10;
127
+ j++;
120
128
  } else if (usernames.length > 0) {
121
- autoCollectMax = parseInt(positional[j]) || 1; j++;
122
- autoScrapeDepth = parseInt(positional[j]) || 50; j++;
123
- autoMaxComments = parseInt(positional[j]) || 200; j++;
129
+ autoCollectMax = parseInt(positional[j]) || 1;
130
+ j++;
131
+ autoScrapeDepth = parseInt(positional[j]) || 50;
132
+ j++;
133
+ autoMaxComments = parseInt(positional[j]) || 200;
134
+ j++;
124
135
  autoMaxGuess = parseInt(positional[j]) || 10;
125
136
  }
126
137
 
127
138
  return {
128
- subcommand: 'auto',
139
+ subcommand: "auto",
129
140
  autoUsernames: usernames,
130
141
  autoCollectMax,
131
142
  autoScrapeDepth,
@@ -139,7 +150,7 @@ function parseAutoArgs(args) {
139
150
  autoMaxFollowing,
140
151
  autoMaxFollowers,
141
152
  urls: [],
142
- outputFormat: 'json',
153
+ outputFormat: "json",
143
154
  exploreCount: 0,
144
155
  showConfig: false,
145
156
  showHelp: false,
@@ -153,49 +164,52 @@ function parseAutoArgs(args) {
153
164
 
154
165
  function parseExploreArgs(args) {
155
166
  let serverUrl = defaultServer;
156
- let explorePreset = 'normal';
167
+ let explorePreset = "normal";
157
168
  let exploreMaxComments = 10;
158
169
  let exploreMaxGuess = 0;
159
170
  let exploreEnableFollow = true;
160
171
  let exploreMaxFollowing = 50;
161
172
  let exploreMaxFollowers = 50;
162
- let exploreLocation = 'PL,NL,BE,DE,FR,IT,ES,IE';
173
+ let exploreLocation = "PL,NL,BE,DE,FR,IT,ES,IE";
163
174
  let exploreMaxUsers = 0;
164
175
  let explorePort = null;
165
- let exploreProfile = null;
176
+ let exploreBasePort = null;
177
+ let explorePortCount = null;
166
178
  let exploreUserId = null;
167
179
  let exploreMaxVideos = 16;
168
180
 
169
181
  const positional = [];
170
- const PRESETS = ['fast', 'normal', 'slow', 'stealth'];
182
+ const PRESETS = ["fast", "normal", "slow", "stealth"];
171
183
 
172
184
  for (let i = 0; i < args.length; i++) {
173
185
  const arg = args[i];
174
- if (arg === '--server') {
186
+ if (arg === "--server") {
175
187
  serverUrl = args[++i];
176
- } else if (arg === '--max-comments') {
188
+ } else if (arg === "--max-comments") {
177
189
  exploreMaxComments = parseInt(args[++i]) || 0;
178
- } else if (arg === '--max-guess') {
190
+ } else if (arg === "--max-guess") {
179
191
  exploreMaxGuess = parseInt(args[++i]) || 0;
180
- } else if (arg === '--location') {
192
+ } else if (arg === "--location") {
181
193
  exploreLocation = args[++i];
182
- } else if (arg === '--enable-follow') {
194
+ } else if (arg === "--enable-follow") {
183
195
  exploreEnableFollow = true;
184
- } else if (arg === '--disable-follow') {
196
+ } else if (arg === "--disable-follow") {
185
197
  exploreEnableFollow = false;
186
- } else if (arg === '--max-following') {
198
+ } else if (arg === "--max-following") {
187
199
  exploreMaxFollowing = parseInt(args[++i]) || 50;
188
200
 
189
201
  exploreMaxFollowers = parseInt(args[++i]) || 50;
190
- } else if (arg === '--max-users') {
202
+ } else if (arg === "--max-users") {
191
203
  exploreMaxUsers = parseInt(args[++i]) || 0;
192
- } else if (arg === '--port') {
204
+ } else if (arg === "--port") {
193
205
  explorePort = parseInt(args[++i]) || 9222;
194
- } else if (arg === '--profile') {
195
- exploreProfile = args[++i];
196
- } else if (arg === '--user-id') {
206
+ } else if (arg === "--base-port") {
207
+ exploreBasePort = parseInt(args[++i]) || 9222;
208
+ } else if (arg === "--port-count") {
209
+ explorePortCount = parseInt(args[++i]) || 10;
210
+ } else if (arg === "--user-id") {
197
211
  exploreUserId = args[++i];
198
- } else if (arg === '--max-videos') {
212
+ } else if (arg === "--max-videos") {
199
213
  exploreMaxVideos = parseInt(args[++i]) || 16;
200
214
  } else {
201
215
  positional.push(arg);
@@ -204,8 +218,12 @@ function parseExploreArgs(args) {
204
218
 
205
219
  const usernames = [];
206
220
  let j = 0;
207
- while (j < positional.length && !PRESETS.includes(positional[j]?.toLowerCase()) && isNaN(positional[j])) {
208
- usernames.push(positional[j].replace('@', ''));
221
+ while (
222
+ j < positional.length &&
223
+ !PRESETS.includes(positional[j]?.toLowerCase()) &&
224
+ isNaN(positional[j])
225
+ ) {
226
+ usernames.push(positional[j].replace("@", ""));
209
227
  j++;
210
228
  }
211
229
 
@@ -215,7 +233,7 @@ function parseExploreArgs(args) {
215
233
  }
216
234
 
217
235
  return {
218
- subcommand: 'explore',
236
+ subcommand: "explore",
219
237
  exploreUsernames: usernames,
220
238
  explorePreset,
221
239
  exploreMaxComments,
@@ -227,11 +245,12 @@ function parseExploreArgs(args) {
227
245
  serverUrl,
228
246
  exploreMaxUsers,
229
247
  explorePort,
230
- exploreProfile,
248
+ exploreBasePort,
249
+ explorePortCount,
231
250
  exploreUserId,
232
251
  exploreMaxVideos,
233
252
  urls: [],
234
- outputFormat: 'json',
253
+ outputFormat: "json",
235
254
  exploreCount: 0,
236
255
  showConfig: false,
237
256
  showHelp: false,
@@ -252,23 +271,23 @@ function parseVideosArgs(args) {
252
271
 
253
272
  for (let i = 0; i < args.length; i++) {
254
273
  const arg = args[i];
255
- if (arg === '-o' || arg === '--output') {
274
+ if (arg === "-o" || arg === "--output") {
256
275
  outputFile = args[++i];
257
276
  } else {
258
277
  positional.push(arg);
259
278
  }
260
279
  }
261
280
 
262
- videosUsername = positional[0] ? positional[0].replace('@', '') : null;
281
+ videosUsername = positional[0] ? positional[0].replace("@", "") : null;
263
282
  videosMax = parseInt(positional[1]) || 5;
264
283
 
265
284
  return {
266
- subcommand: 'videos',
285
+ subcommand: "videos",
267
286
  videosUsername,
268
287
  videosMax,
269
288
  outputFile,
270
289
  urls: [],
271
- outputFormat: 'json',
290
+ outputFormat: "json",
272
291
  exploreCount: 0,
273
292
  showConfig: false,
274
293
  showHelp: false,
@@ -286,19 +305,19 @@ function parseInfoArgs(args) {
286
305
 
287
306
  for (let i = 0; i < args.length; i++) {
288
307
  const arg = args[i];
289
- if (arg === '--onlyvideo') {
308
+ if (arg === "--onlyvideo") {
290
309
  onlyVideo = true;
291
- } else if (!arg.startsWith('--')) {
310
+ } else if (!arg.startsWith("--")) {
292
311
  urls.push(arg);
293
312
  }
294
313
  }
295
314
 
296
315
  return {
297
- subcommand: 'info',
316
+ subcommand: "info",
298
317
  infoUrls: urls,
299
318
  infoOnlyVideo: onlyVideo,
300
319
  outputFile: null,
301
- outputFormat: 'json',
320
+ outputFormat: "json",
302
321
  exploreCount: 0,
303
322
  showConfig: false,
304
323
  showHelp: false,
@@ -313,24 +332,24 @@ function parseInfoArgs(args) {
313
332
  }
314
333
 
315
334
  function parseWatchArgs(args) {
316
- let outputFile = './result.json';
335
+ let outputFile = "./result.json";
317
336
  let watchPort = 3001;
318
337
 
319
338
  for (let i = 0; i < args.length; i++) {
320
339
  const arg = args[i];
321
- if (arg === '-o' || arg === '--output') {
340
+ if (arg === "-o" || arg === "--output") {
322
341
  outputFile = args[++i];
323
- } else if (arg === '-p') {
342
+ } else if (arg === "-p") {
324
343
  watchPort = parseInt(args[++i]) || 3001;
325
344
  }
326
345
  }
327
346
 
328
347
  return {
329
- subcommand: 'watch',
348
+ subcommand: "watch",
330
349
  outputFile,
331
350
  watchPort,
332
351
  urls: [],
333
- outputFormat: 'json',
352
+ outputFormat: "json",
334
353
  exploreCount: 0,
335
354
  showConfig: false,
336
355
  showHelp: false,
@@ -344,7 +363,7 @@ function parseWatchArgs(args) {
344
363
 
345
364
  function parseRefreshArgs(args) {
346
365
  let serverUrl = defaultServer;
347
- let explorePreset = 'normal';
366
+ let explorePreset = "normal";
348
367
  let exploreMaxComments = 10;
349
368
  let exploreMaxGuess = 0;
350
369
  let explorePort = null;
@@ -353,25 +372,25 @@ function parseRefreshArgs(args) {
353
372
 
354
373
  for (let i = 0; i < args.length; i++) {
355
374
  const arg = args[i];
356
- if (arg === '--server') {
375
+ if (arg === "--server") {
357
376
  serverUrl = args[++i];
358
- } else if (arg === '--comments') {
377
+ } else if (arg === "--comments") {
359
378
  exploreMaxComments = parseInt(args[++i]) || 10;
360
- } else if (arg === '--guess') {
379
+ } else if (arg === "--guess") {
361
380
  exploreMaxGuess = parseInt(args[++i]) || 0;
362
- } else if (arg === '--preset') {
381
+ } else if (arg === "--preset") {
363
382
  explorePreset = args[++i];
364
- } else if (arg === '--port') {
383
+ } else if (arg === "--port") {
365
384
  explorePort = parseInt(args[++i]) || 9222;
366
- } else if (arg === '--profile') {
385
+ } else if (arg === "--profile") {
367
386
  exploreProfile = args[++i];
368
- } else if (arg === '--user-id') {
387
+ } else if (arg === "--user-id") {
369
388
  exploreUserId = args[++i];
370
389
  }
371
390
  }
372
391
 
373
392
  return {
374
- subcommand: 'refresh',
393
+ subcommand: "refresh",
375
394
  explorePreset,
376
395
  exploreMaxComments,
377
396
  exploreMaxGuess,
@@ -380,7 +399,7 @@ function parseRefreshArgs(args) {
380
399
  exploreUserId,
381
400
  serverUrl,
382
401
  urls: [],
383
- outputFormat: 'json',
402
+ outputFormat: "json",
384
403
  exploreCount: 0,
385
404
  showConfig: false,
386
405
  showHelp: false,
@@ -399,22 +418,22 @@ function parseAttachArgs(args) {
399
418
 
400
419
  for (let i = 0; i < args.length; i++) {
401
420
  const arg = args[i];
402
- if (arg === '-p' || arg === '--parallel') {
421
+ if (arg === "-p" || arg === "--parallel") {
403
422
  parallel = parseInt(args[++i], 10) || 1;
404
- } else if (arg === '-i' || arg === '--interval') {
423
+ } else if (arg === "-i" || arg === "--interval") {
405
424
  interval = parseInt(args[++i], 10) || 10;
406
- } else if (arg === '-s' || arg === '--server') {
425
+ } else if (arg === "-s" || arg === "--server") {
407
426
  serverUrl = args[++i];
408
427
  }
409
428
  }
410
429
 
411
430
  return {
412
- subcommand: 'attach',
431
+ subcommand: "attach",
413
432
  attachParallel: parallel,
414
433
  attachInterval: interval,
415
434
  serverUrl,
416
435
  urls: [],
417
- outputFormat: 'json',
436
+ outputFormat: "json",
418
437
  exploreCount: 0,
419
438
  showConfig: false,
420
439
  showHelp: false,
@@ -432,19 +451,108 @@ function parseOpenArgs(args) {
432
451
 
433
452
  for (let i = 0; i < args.length; i++) {
434
453
  const arg = args[i];
435
- if (arg === '--list') {
454
+ if (arg === "--list") {
436
455
  openList = true;
437
- } else if (!arg.startsWith('-')) {
456
+ } else if (!arg.startsWith("-")) {
438
457
  openPort = arg;
439
458
  }
440
459
  }
441
460
 
442
461
  return {
443
- subcommand: 'open',
462
+ subcommand: "open",
444
463
  openPort,
445
464
  openList,
446
465
  urls: [],
447
- outputFormat: 'json',
466
+ outputFormat: "json",
467
+ exploreCount: 0,
468
+ showConfig: false,
469
+ showHelp: false,
470
+ customProxy: null,
471
+ configAction: null,
472
+ configValue: null,
473
+ pipeMode: false,
474
+ filterStr: null,
475
+ };
476
+ }
477
+
478
+ function parseVideoStatsArgs(args) {
479
+ let statsFile = null;
480
+ let statsParallel = 3;
481
+
482
+ for (let i = 0; i < args.length; i++) {
483
+ const arg = args[i];
484
+ if (arg === "-p" || arg === "--parallel") {
485
+ statsParallel = parseInt(args[++i]) || 3;
486
+ } else if (!arg.startsWith("-")) {
487
+ statsFile = args[i] || null;
488
+ }
489
+ }
490
+
491
+ return {
492
+ subcommand: "videostats",
493
+ statsFile,
494
+ statsParallel,
495
+ commentsUrl: null,
496
+ commentsMax: 20,
497
+ commentsSave: false,
498
+ commentsParallel: 1,
499
+ commentsInterval: 10,
500
+ commentsServer: defaultServer,
501
+ urls: [],
502
+ outputFormat: "json",
503
+ exploreCount: 0,
504
+ showConfig: false,
505
+ showHelp: false,
506
+ customProxy: null,
507
+ configAction: null,
508
+ configValue: null,
509
+ pipeMode: false,
510
+ filterStr: null,
511
+ };
512
+ }
513
+
514
+ function parseCommentsArgs(args) {
515
+ let commentsUrl = null;
516
+ let commentsMax = 20;
517
+ let commentsSave = false;
518
+ let commentsParallel = 1;
519
+ let commentsInterval = 10;
520
+ let commentsServer = defaultServer;
521
+
522
+ const positional = [];
523
+
524
+ for (let i = 0; i < args.length; i++) {
525
+ const arg = args[i];
526
+ if (arg === "--save") {
527
+ commentsSave = true;
528
+ } else if (arg === "-p" || arg === "--parallel") {
529
+ commentsParallel = parseInt(args[++i]) || 1;
530
+ } else if (arg === "-i" || arg === "--interval") {
531
+ commentsInterval = parseInt(args[++i]) || 10;
532
+ } else if (arg === "-s" || arg === "--server") {
533
+ commentsServer = args[++i];
534
+ } else if (arg === "-m" || arg === "--max-comments") {
535
+ commentsMax = parseInt(args[++i]) || 20;
536
+ } else {
537
+ positional.push(arg);
538
+ }
539
+ }
540
+
541
+ commentsUrl = positional[0] || null;
542
+ if (positional[1]) {
543
+ commentsMax = parseInt(positional[1]) || 20;
544
+ }
545
+
546
+ return {
547
+ subcommand: "comments",
548
+ commentsUrl,
549
+ commentsMax,
550
+ commentsSave,
551
+ commentsParallel,
552
+ commentsInterval,
553
+ commentsServer,
554
+ urls: [],
555
+ outputFormat: "json",
448
556
  exploreCount: 0,
449
557
  showConfig: false,
450
558
  showHelp: false,
@@ -459,37 +567,73 @@ function parseOpenArgs(args) {
459
567
  export function parseArgs() {
460
568
  const args = process.argv.slice(2);
461
569
 
462
- if (args.includes('-h') || args.includes('--help')) {
463
- return { showHelp: true, showVersion: false, subcommand: null, urls: [], outputFile: null, outputFormat: 'json', exploreCount: 0, showConfig: false, customProxy: null, configAction: null, configValue: null, pipeMode: false, filterStr: null };
570
+ if (args.includes("-h") || args.includes("--help")) {
571
+ return {
572
+ showHelp: true,
573
+ showVersion: false,
574
+ subcommand: null,
575
+ urls: [],
576
+ outputFile: null,
577
+ outputFormat: "json",
578
+ exploreCount: 0,
579
+ showConfig: false,
580
+ customProxy: null,
581
+ configAction: null,
582
+ configValue: null,
583
+ pipeMode: false,
584
+ filterStr: null,
585
+ };
464
586
  }
465
- if (args.includes('--version')) {
466
- return { showHelp: false, showVersion: true, subcommand: null, urls: [], outputFile: null, outputFormat: 'json', exploreCount: 0, showConfig: false, customProxy: null, configAction: null, configValue: null, pipeMode: false, filterStr: null };
587
+ if (args.includes("--version")) {
588
+ return {
589
+ showHelp: false,
590
+ showVersion: true,
591
+ subcommand: null,
592
+ urls: [],
593
+ outputFile: null,
594
+ outputFormat: "json",
595
+ exploreCount: 0,
596
+ showConfig: false,
597
+ customProxy: null,
598
+ configAction: null,
599
+ configValue: null,
600
+ pipeMode: false,
601
+ filterStr: null,
602
+ };
467
603
  }
468
604
 
469
- if (args.length > 0 && args[0] === 'explore') {
605
+ if (args.length > 0 && args[0] === "explore") {
470
606
  return parseExploreArgs(args.slice(1));
471
607
  }
472
608
 
473
- if (args.length > 0 && args[0] === 'info') {
609
+ if (args.length > 0 && args[0] === "info") {
474
610
  return parseInfoArgs(args.slice(1));
475
611
  }
476
612
 
477
- if (args.length > 0 && args[0] === 'watch') {
613
+ if (args.length > 0 && args[0] === "watch") {
478
614
  return parseWatchArgs(args.slice(1));
479
615
  }
480
616
 
481
- if (args.length > 0 && args[0] === 'attach') {
617
+ if (args.length > 0 && args[0] === "attach") {
482
618
  return parseAttachArgs(args.slice(1));
483
619
  }
484
620
 
485
- if (args.length > 0 && args[0] === 'open') {
621
+ if (args.length > 0 && args[0] === "open") {
486
622
  return parseOpenArgs(args.slice(1));
487
623
  }
488
624
 
625
+ if (args.length > 0 && args[0] === "comments") {
626
+ return parseCommentsArgs(args.slice(1));
627
+ }
628
+
629
+ if (args.length > 0 && args[0] === "videostats") {
630
+ return parseVideoStatsArgs(args.slice(1));
631
+ }
632
+
489
633
  const urls = [];
490
634
  let inputFile = null;
491
635
  let outputFile = null;
492
- let outputFormat = 'json';
636
+ let outputFormat = "json";
493
637
  let exploreCount = 0;
494
638
  let showConfig = false;
495
639
  let showHelp = false;
@@ -504,49 +648,71 @@ export function parseArgs() {
504
648
  for (let i = 0; i < args.length; i++) {
505
649
  const arg = args[i];
506
650
 
507
- if (arg === '--explore') {
508
- exploreCount = args[i + 1] && !args[i + 1].startsWith('http')
509
- ? parseInt(args[++i], 10)
510
- : 100;
511
- } else if (arg === '--proxy') {
651
+ if (arg === "--explore") {
652
+ exploreCount =
653
+ args[i + 1] && !args[i + 1].startsWith("http")
654
+ ? parseInt(args[++i], 10)
655
+ : 100;
656
+ } else if (arg === "--proxy") {
512
657
  customProxy = args[++i];
513
- } else if (arg === '--filter') {
658
+ } else if (arg === "--filter") {
514
659
  filterStr = args[++i];
515
- } else if (arg === 'config') {
660
+ } else if (arg === "config") {
516
661
  configAction = args[i + 1];
517
662
  if (!configAction) {
518
- configAction = 'show';
519
- } else if (configAction === 'set' || configAction === 'set-proxy' || configAction === 'set-browser') {
663
+ configAction = "show";
664
+ } else if (
665
+ configAction === "set" ||
666
+ configAction === "set-proxy" ||
667
+ configAction === "set-browser"
668
+ ) {
520
669
  configKey = args[i + 2];
521
670
  configValue = args[i + 3];
522
671
  i += 3;
523
672
  } else {
524
673
  i++;
525
674
  }
526
- } else if (arg === '--pipe') {
675
+ } else if (arg === "--pipe") {
527
676
  pipeMode = true;
528
- } else if (arg === '-i' || arg === '--input') {
677
+ } else if (arg === "-i" || arg === "--input") {
529
678
  inputFile = args[++i];
530
- } else if (arg === '-o' || arg === '--output') {
679
+ } else if (arg === "-o" || arg === "--output") {
531
680
  outputFile = args[++i];
532
- } else if (arg === '-f' || arg === '--format') {
681
+ } else if (arg === "-f" || arg === "--format") {
533
682
  outputFormat = args[++i];
534
- } else if (arg === '-c' || arg === '--config') {
683
+ } else if (arg === "-c" || arg === "--config") {
535
684
  showConfig = true;
536
- } else if (arg === '-h' || arg === '--help') {
685
+ } else if (arg === "-h" || arg === "--help") {
537
686
  showHelp = true;
538
- } else if (arg === '--version') {
687
+ } else if (arg === "--version") {
539
688
  showVersion = true;
540
- } else if (arg.startsWith('http')) {
689
+ } else if (arg.startsWith("http")) {
541
690
  urls.push(arg);
542
691
  }
543
692
  }
544
693
 
545
694
  if (inputFile) {
546
- const content = readFileSync(inputFile, 'utf-8');
547
- const lines = content.split(/\r?\n/).map(l => l.trim()).filter(l => l.startsWith('http'));
695
+ const content = readFileSync(inputFile, "utf-8");
696
+ const lines = content
697
+ .split(/\r?\n/)
698
+ .map((l) => l.trim())
699
+ .filter((l) => l.startsWith("http"));
548
700
  urls.push(...lines);
549
701
  }
550
702
 
551
- return { urls, outputFile, outputFormat, exploreCount, showConfig, showHelp, showVersion, customProxy, configAction, configKey, configValue, pipeMode, filterStr };
552
- }
703
+ return {
704
+ urls,
705
+ outputFile,
706
+ outputFormat,
707
+ exploreCount,
708
+ showConfig,
709
+ showHelp,
710
+ showVersion,
711
+ customProxy,
712
+ configAction,
713
+ configKey,
714
+ configValue,
715
+ pipeMode,
716
+ filterStr,
717
+ };
718
+ }