@seamapi/cli 0.13.0 → 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 +26 -2
- 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/completion/render-fish.js +2 -2
- 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 +6 -4
- package/src/bin/cli.ts +111 -29
- package/src/lib/command-spec.ts +12 -0
- package/src/lib/completion/render-fish.ts +2 -2
- 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
|
@@ -10,16 +10,16 @@ type UpdatedCustomMetadata = {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const interactForCustomMetadata = async (
|
|
13
|
-
|
|
13
|
+
customMetadata: CustomMetadata,
|
|
14
14
|
) => {
|
|
15
|
-
const
|
|
15
|
+
const updatedCustomMetadata: UpdatedCustomMetadata = { ...customMetadata }
|
|
16
16
|
const output = getOutput()
|
|
17
17
|
|
|
18
18
|
const displayCurrentCustomMetadata = () => {
|
|
19
19
|
output.info('custom_metadata:')
|
|
20
|
-
if (Object.keys(
|
|
21
|
-
Object.keys(
|
|
22
|
-
output.info(`${index + 1}: ${key}: ${
|
|
20
|
+
if (Object.keys(updatedCustomMetadata).length > 0) {
|
|
21
|
+
Object.keys(updatedCustomMetadata).forEach((key, index) => {
|
|
22
|
+
output.info(`${index + 1}: ${key}: ${updatedCustomMetadata[key]}`)
|
|
23
23
|
})
|
|
24
24
|
} else {
|
|
25
25
|
output.info('The custom metadata param is empty.')
|
|
@@ -61,31 +61,29 @@ export const interactForCustomMetadata = async (
|
|
|
61
61
|
newValue = Boolean(newValue)
|
|
62
62
|
}
|
|
63
63
|
if (newValue === 'null') {
|
|
64
|
-
|
|
64
|
+
updatedCustomMetadata[newKey] = null
|
|
65
65
|
} else {
|
|
66
|
-
|
|
66
|
+
updatedCustomMetadata[newKey] = newValue
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
} else if (action === 'remove') {
|
|
70
|
-
const {
|
|
70
|
+
const { customKeyToRemove } = await prompt({
|
|
71
71
|
type: 'select',
|
|
72
|
-
name: '
|
|
72
|
+
name: 'customKeyToRemove',
|
|
73
73
|
message: 'Choose a key-value pair to remove from params:',
|
|
74
|
-
choices: Object.keys(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
),
|
|
74
|
+
choices: Object.keys(updatedCustomMetadata).map((customMetadataKey) => {
|
|
75
|
+
return {
|
|
76
|
+
title: `${customMetadataKey}: ${updatedCustomMetadata[customMetadataKey]}`,
|
|
77
|
+
value: customMetadataKey,
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
82
80
|
})
|
|
83
81
|
|
|
84
|
-
if (
|
|
85
|
-
delete
|
|
82
|
+
if (customKeyToRemove) {
|
|
83
|
+
delete customMetadata[customKeyToRemove]
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
} while (action !== 'done')
|
|
89
87
|
|
|
90
|
-
return
|
|
88
|
+
return updatedCustomMetadata
|
|
91
89
|
}
|
|
@@ -3,10 +3,10 @@ import { getOutput } from './output/get-output.js'
|
|
|
3
3
|
import { prompt } from './util/prompt.js'
|
|
4
4
|
|
|
5
5
|
export async function interactForUseRemoteApiDefs() {
|
|
6
|
-
const {
|
|
6
|
+
const { useRemoteApiDefs } = await prompt([
|
|
7
7
|
{
|
|
8
8
|
type: 'select',
|
|
9
|
-
name: '
|
|
9
|
+
name: 'useRemoteApiDefs',
|
|
10
10
|
message: 'Always use remote API Definitions?',
|
|
11
11
|
choices: [
|
|
12
12
|
{
|
|
@@ -22,6 +22,6 @@ export async function interactForUseRemoteApiDefs() {
|
|
|
22
22
|
])
|
|
23
23
|
|
|
24
24
|
const config = getConfigStore()
|
|
25
|
-
config.set('use_remote_api_defs',
|
|
26
|
-
getOutput().info(`Use remote API Definitions: ${
|
|
25
|
+
config.set('use_remote_api_defs', useRemoteApiDefs)
|
|
26
|
+
getOutput().info(`Use remote API Definitions: ${useRemoteApiDefs}`)
|
|
27
27
|
}
|
package/src/lib/render-help.ts
CHANGED
|
@@ -66,6 +66,10 @@ const examples = [
|
|
|
66
66
|
name: "seam access-codes create {bold --code} '1234' {bold --name} 'My Code'",
|
|
67
67
|
summary: 'Create an access code.',
|
|
68
68
|
},
|
|
69
|
+
{
|
|
70
|
+
name: 'seam devices list {bold --page-cursor} $NEXT_PAGE_CURSOR',
|
|
71
|
+
summary: 'List the next page of devices.',
|
|
72
|
+
},
|
|
69
73
|
{
|
|
70
74
|
name: 'seam devices list > devices.json',
|
|
71
75
|
summary: 'Write the response to a file as JSON.',
|
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