@bobfrankston/gcards 0.1.13 → 0.1.14

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.
Files changed (2) hide show
  1. package/glib/parsecli.ts +39 -18
  2. package/package.json +1 -1
package/glib/parsecli.ts CHANGED
@@ -27,29 +27,50 @@ export function parseArgs(args: string[]): CliOptions {
27
27
  since: ''
28
28
  };
29
29
 
30
+ const unrecognized: string[] = [];
31
+
30
32
  for (let i = 0; i < args.length; i++) {
31
33
  const arg = args[i];
32
- if (arg === '--full' || arg === '-f') {
33
- options.full = true;
34
- } else if (arg === '--yes' || arg === '-y') {
35
- options.yes = true;
36
- } else if (arg === '--help' || arg === '-h') {
37
- options.help = true;
38
- } else if (arg === '--verbose' || arg === '-v') {
39
- options.verbose = true;
40
- } else if (arg === '--all' || arg === '-all' || arg === '-a') {
41
- options.all = true;
42
- } else if ((arg === '--user' || arg === '-user' || arg === '-u') && i + 1 < args.length) {
43
- options.user = args[++i];
44
- } else if ((arg === '--limit' || arg === '-limit') && i + 1 < args.length) {
45
- options.limit = parseInt(args[++i], 10) || 0;
46
- } else if ((arg === '--since' || arg === '-since') && i + 1 < args.length) {
47
- options.since = args[++i];
48
- } else if (!arg.startsWith('-') && !options.command) {
49
- options.command = arg;
34
+ switch (arg) {
35
+ case '--full': case '-full': case '-f':
36
+ options.full = true;
37
+ break;
38
+ case '--yes': case '-y':
39
+ options.yes = true;
40
+ break;
41
+ case '--help': case '-h':
42
+ options.help = true;
43
+ break;
44
+ case '--verbose': case '-v':
45
+ options.verbose = true;
46
+ break;
47
+ case '--all': case '-all': case '-a':
48
+ options.all = true;
49
+ break;
50
+ case '--user': case '-user': case '-u':
51
+ options.user = args[++i] || '';
52
+ break;
53
+ case '--limit': case '-limit':
54
+ options.limit = parseInt(args[++i], 10) || 0;
55
+ break;
56
+ case '--since': case '-since':
57
+ options.since = args[++i] || '';
58
+ break;
59
+ default:
60
+ if (!arg.startsWith('-') && !options.command) {
61
+ options.command = arg;
62
+ } else {
63
+ unrecognized.push(arg);
64
+ }
50
65
  }
51
66
  }
52
67
 
68
+ if (unrecognized.length > 0) {
69
+ console.error(`Unrecognized argument(s): ${unrecognized.join(', ')}`);
70
+ console.error(`Use --help for usage information.`);
71
+ process.exit(1);
72
+ }
73
+
53
74
  return options;
54
75
  }
55
76
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/gcards",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Google Contacts cleanup and management tool",
5
5
  "type": "module",
6
6
  "main": "gcards.ts",