@seamapi/cli 0.13.1 → 0.14.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.
Files changed (40) hide show
  1. package/README.md +25 -1
  2. package/bin/cli.js +86 -30
  3. package/bin/cli.js.map +1 -1
  4. package/lib/command-spec.d.ts +8 -0
  5. package/lib/command-spec.js +8 -0
  6. package/lib/command-spec.js.map +1 -1
  7. package/lib/interact-for-access-code.d.ts +1 -1
  8. package/lib/interact-for-access-code.js +7 -4
  9. package/lib/interact-for-access-code.js.map +1 -1
  10. package/lib/interact-for-acs-user.js +2 -2
  11. package/lib/interact-for-acs-user.js.map +1 -1
  12. package/lib/interact-for-action-attempt-poll.d.ts +1 -1
  13. package/lib/interact-for-action-attempt-poll.js +8 -8
  14. package/lib/interact-for-action-attempt-poll.js.map +1 -1
  15. package/lib/interact-for-blueprint-object.js +6 -8
  16. package/lib/interact-for-blueprint-object.js.map +1 -1
  17. package/lib/interact-for-custom-metadata.d.ts +1 -1
  18. package/lib/interact-for-custom-metadata.js +15 -15
  19. package/lib/interact-for-custom-metadata.js.map +1 -1
  20. package/lib/interact-for-use-remote-api-defs.js +4 -4
  21. package/lib/interact-for-use-remote-api-defs.js.map +1 -1
  22. package/lib/render-help.js +4 -0
  23. package/lib/render-help.js.map +1 -1
  24. package/lib/util/cli-args.d.ts +21 -0
  25. package/lib/util/cli-args.js +26 -1
  26. package/lib/util/cli-args.js.map +1 -1
  27. package/lib/version.d.ts +1 -1
  28. package/lib/version.js +1 -1
  29. package/package.json +1 -1
  30. package/src/bin/cli.ts +111 -29
  31. package/src/lib/command-spec.ts +12 -0
  32. package/src/lib/interact-for-access-code.ts +6 -4
  33. package/src/lib/interact-for-acs-user.ts +2 -2
  34. package/src/lib/interact-for-action-attempt-poll.ts +9 -9
  35. package/src/lib/interact-for-blueprint-object.ts +6 -8
  36. package/src/lib/interact-for-custom-metadata.ts +18 -20
  37. package/src/lib/interact-for-use-remote-api-defs.ts +4 -4
  38. package/src/lib/render-help.ts +4 -0
  39. package/src/lib/util/cli-args.ts +33 -1
  40. package/src/lib/version.ts +1 -1
@@ -44,9 +44,27 @@ export class NonInteractiveError extends Error {
44
44
  override name = 'NonInteractiveError'
45
45
  }
46
46
 
47
+ /**
48
+ * Thrown when the arguments do not name something the CLI can run.
49
+ */
50
+ export class UsageError extends Error {
51
+ override name = 'UsageError'
52
+
53
+ /** What to run instead, reported after the message. */
54
+ readonly hint: string
55
+
56
+ constructor(message: string, { hint = '' }: { hint?: string } = {}) {
57
+ super(message)
58
+ this.hint = hint
59
+ }
60
+ }
61
+
47
62
  export const parseCliArgs = (argv: string[]): ParsedArgs =>
48
63
  parseArgs(argv, {
49
- string: ['code'],
64
+ // A page cursor is opaque, so keep it exactly as given: read as a number
65
+ // it would lose leading zeroes and turn exponent notation into a digit
66
+ // string, naming a page the API never issued.
67
+ string: ['code', 'page-cursor', 'page_cursor'],
50
68
  boolean: ['non-interactive', 'interactive', 'json'],
51
69
  // Deliberately not aliased to -n, which is reserved for a future
52
70
  // --dry-run flag.
@@ -90,3 +108,17 @@ export const getInteractivity = (
90
108
  */
91
109
  export const toArgName = (parameterName: string): string =>
92
110
  `--${parameterName.replace(/_/g, '-')}`
111
+
112
+ /**
113
+ * Read an argument key as the parameter it names, e.g., `--page-cursor`,
114
+ * `--page_cursor`, and `--PAGE-CURSOR` all name `page_cursor`.
115
+ */
116
+ export const toParameterName = (argKey: string): string =>
117
+ argKey.toLowerCase().replace(/-/g, '_')
118
+
119
+ /**
120
+ * Render an argument key as the argument it was given as, naming a one letter
121
+ * key as the short form it can only have been written as, e.g., `-n`.
122
+ */
123
+ export const toGivenArgName = (argKey: string): string =>
124
+ argKey.length === 1 ? `-${argKey}` : toArgName(argKey)
@@ -1,5 +1,5 @@
1
1
  // Versions are replaced with generated values when the package is packed.
2
- const seamapiCliVersion = '0.13.1'
2
+ const seamapiCliVersion = '0.14.0'
3
3
  const seamapiBlueprintVersion = '1.2.0'
4
4
 
5
5
  export { seamapiBlueprintVersion }