@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.
- package/README.md +25 -1
- package/bin/cli.js +86 -30
- package/bin/cli.js.map +1 -1
- package/lib/command-spec.d.ts +8 -0
- package/lib/command-spec.js +8 -0
- package/lib/command-spec.js.map +1 -1
- package/lib/interact-for-access-code.d.ts +1 -1
- package/lib/interact-for-access-code.js +7 -4
- package/lib/interact-for-access-code.js.map +1 -1
- package/lib/interact-for-acs-user.js +2 -2
- package/lib/interact-for-acs-user.js.map +1 -1
- package/lib/interact-for-action-attempt-poll.d.ts +1 -1
- package/lib/interact-for-action-attempt-poll.js +8 -8
- package/lib/interact-for-action-attempt-poll.js.map +1 -1
- package/lib/interact-for-blueprint-object.js +6 -8
- package/lib/interact-for-blueprint-object.js.map +1 -1
- package/lib/interact-for-custom-metadata.d.ts +1 -1
- package/lib/interact-for-custom-metadata.js +15 -15
- package/lib/interact-for-custom-metadata.js.map +1 -1
- package/lib/interact-for-use-remote-api-defs.js +4 -4
- package/lib/interact-for-use-remote-api-defs.js.map +1 -1
- package/lib/render-help.js +4 -0
- package/lib/render-help.js.map +1 -1
- package/lib/util/cli-args.d.ts +21 -0
- package/lib/util/cli-args.js +26 -1
- package/lib/util/cli-args.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/bin/cli.ts +111 -29
- package/src/lib/command-spec.ts +12 -0
- package/src/lib/interact-for-access-code.ts +6 -4
- package/src/lib/interact-for-acs-user.ts +2 -2
- package/src/lib/interact-for-action-attempt-poll.ts +9 -9
- package/src/lib/interact-for-blueprint-object.ts +6 -8
- package/src/lib/interact-for-custom-metadata.ts +18 -20
- package/src/lib/interact-for-use-remote-api-defs.ts +4 -4
- package/src/lib/render-help.ts +4 -0
- package/src/lib/util/cli-args.ts +33 -1
- package/src/lib/version.ts +1 -1
package/src/lib/util/cli-args.ts
CHANGED
|
@@ -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
|
-
|
|
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)
|
package/src/lib/version.ts
CHANGED