@verbatims/cli 0.1.10 → 0.1.12
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/package.json +1 -1
- package/src/commands/authors.ts +35 -2
- package/src/commands/references.ts +39 -3
package/package.json
CHANGED
package/src/commands/authors.ts
CHANGED
|
@@ -47,6 +47,8 @@ export function registerAuthorsCommand(program: Command) {
|
|
|
47
47
|
.option('--name <name>', 'Author name')
|
|
48
48
|
.option('--job <job>', 'Job title')
|
|
49
49
|
.option('--description <text>', 'Description')
|
|
50
|
+
.option('--image-url <url>', 'Image URL')
|
|
51
|
+
.option('--fictional', 'Mark as fictional')
|
|
50
52
|
.action(async (options: Record<string, string>) => {
|
|
51
53
|
const client = await getClient()
|
|
52
54
|
const format = getFormat(program)
|
|
@@ -55,7 +57,13 @@ export function registerAuthorsCommand(program: Command) {
|
|
|
55
57
|
if (isCancel(name)) cancel('Cancelled')
|
|
56
58
|
|
|
57
59
|
const { data } = await withSpinner('Creating author', () =>
|
|
58
|
-
client.authors.create({
|
|
60
|
+
client.authors.create({
|
|
61
|
+
name: name as string,
|
|
62
|
+
job: options.job ?? null,
|
|
63
|
+
description: options.description ?? null,
|
|
64
|
+
image_url: options.imageUrl ?? null,
|
|
65
|
+
fictional: options.fictional !== undefined ? true : undefined,
|
|
66
|
+
}),
|
|
59
67
|
format,
|
|
60
68
|
)
|
|
61
69
|
console.log(chalk.green(' Author created'))
|
|
@@ -66,20 +74,45 @@ export function registerAuthorsCommand(program: Command) {
|
|
|
66
74
|
.command('update <id>')
|
|
67
75
|
.description('Update an author')
|
|
68
76
|
.option('--name <name>', 'Author name')
|
|
77
|
+
.option('--job <job>', 'Job title')
|
|
69
78
|
.option('--description <text>', 'Description')
|
|
79
|
+
.option('--image-url <url>', 'Image URL')
|
|
80
|
+
.option('--fictional', 'Mark as fictional')
|
|
81
|
+
.option('--no-fictional', 'Mark as not fictional')
|
|
70
82
|
.action(async (id: string, options: Record<string, string>) => {
|
|
71
83
|
const client = await getClient()
|
|
72
84
|
const format = getFormat(program)
|
|
73
85
|
|
|
74
86
|
const data_: Record<string, unknown> = {}
|
|
75
87
|
if (options.name) data_.name = options.name
|
|
76
|
-
if (options.
|
|
88
|
+
if (options.job !== undefined) data_.job = options.job || null
|
|
89
|
+
if (options.description !== undefined) data_.description = options.description || null
|
|
90
|
+
if (options.imageUrl !== undefined) data_.image_url = options.imageUrl || null
|
|
91
|
+
if (options.fictional !== undefined) data_.is_fictional = true
|
|
92
|
+
if (options.noFictional !== undefined) data_.is_fictional = false
|
|
77
93
|
|
|
78
94
|
const { data } = await withSpinner('Updating author', () => client.authors.update(Number(id), data_ as any), format)
|
|
79
95
|
console.log(chalk.green(' Author updated'))
|
|
80
96
|
output(data, format)
|
|
81
97
|
})
|
|
82
98
|
|
|
99
|
+
authors
|
|
100
|
+
.command('delete <id>')
|
|
101
|
+
.description('Delete an author')
|
|
102
|
+
.option('--strategy <strategy>', 'Strategy if quotes exist: delete or anonymize')
|
|
103
|
+
.option('--yes', 'Skip confirmation')
|
|
104
|
+
.action(async (id: string, options: Record<string, string>) => {
|
|
105
|
+
if (!options.yes) {
|
|
106
|
+
const { confirm } = await import('@clack/prompts')
|
|
107
|
+
const confirmed = await confirm({ message: `Delete author #${id}?` })
|
|
108
|
+
if (isCancel(confirmed) || !confirmed) cancel('Cancelled')
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const client = await getClient()
|
|
112
|
+
await withSpinner('Deleting author', () => client.authors.delete(Number(id), options.strategy as 'delete' | 'anonymize' | undefined))
|
|
113
|
+
console.log(chalk.green(` Author #${id} deleted`))
|
|
114
|
+
})
|
|
115
|
+
|
|
83
116
|
authors
|
|
84
117
|
.command('browse')
|
|
85
118
|
.description('Browse authors interactively')
|
|
@@ -49,6 +49,8 @@ export function registerReferencesCommand(program: Command) {
|
|
|
49
49
|
.option('--type <type>', 'Primary type')
|
|
50
50
|
.option('--description <text>', 'Description')
|
|
51
51
|
.option('--language <lang>', 'Original language')
|
|
52
|
+
.option('--release-date <date>', 'Release date')
|
|
53
|
+
.option('--image-url <url>', 'Image URL')
|
|
52
54
|
.action(async (options: Record<string, string>) => {
|
|
53
55
|
const client = await getClient()
|
|
54
56
|
const format = getFormat(program)
|
|
@@ -60,7 +62,16 @@ export function registerReferencesCommand(program: Command) {
|
|
|
60
62
|
if (isCancel(primaryType)) cancel('Cancelled')
|
|
61
63
|
|
|
62
64
|
const { data } = await withSpinner('Creating reference', () =>
|
|
63
|
-
client.references.create({
|
|
65
|
+
client.references.create({
|
|
66
|
+
name: name as string,
|
|
67
|
+
type: primaryType as string,
|
|
68
|
+
primary_type: primaryType as string,
|
|
69
|
+
description: options.description ?? null,
|
|
70
|
+
language: options.language,
|
|
71
|
+
original_language: options.language,
|
|
72
|
+
release_date: options.releaseDate ?? null,
|
|
73
|
+
image_url: options.imageUrl ?? null,
|
|
74
|
+
}),
|
|
64
75
|
format,
|
|
65
76
|
)
|
|
66
77
|
console.log(chalk.green(' Reference created'))
|
|
@@ -71,20 +82,45 @@ export function registerReferencesCommand(program: Command) {
|
|
|
71
82
|
.command('update <id>')
|
|
72
83
|
.description('Update a reference')
|
|
73
84
|
.option('--name <name>', 'Reference name')
|
|
85
|
+
.option('--type <type>', 'Primary type')
|
|
74
86
|
.option('--description <text>', 'Description')
|
|
87
|
+
.option('--language <lang>', 'Language')
|
|
88
|
+
.option('--release-date <date>', 'Release date')
|
|
89
|
+
.option('--image-url <url>', 'Image URL')
|
|
75
90
|
.action(async (id: string, options: Record<string, string>) => {
|
|
76
91
|
const client = await getClient()
|
|
77
92
|
const format = getFormat(program)
|
|
78
93
|
|
|
79
94
|
const data_: Record<string, unknown> = {}
|
|
80
|
-
if (options.name)
|
|
81
|
-
if (options.
|
|
95
|
+
if (options.name) data_.name = options.name
|
|
96
|
+
if (options.type !== undefined) { data_.type = options.type; data_.primary_type = options.type }
|
|
97
|
+
if (options.description !== undefined) data_.description = options.description || null
|
|
98
|
+
if (options.language !== undefined) data_.language = options.language || null
|
|
99
|
+
if (options.releaseDate !== undefined) data_.release_date = options.releaseDate || null
|
|
100
|
+
if (options.imageUrl !== undefined) data_.image_url = options.imageUrl || null
|
|
82
101
|
|
|
83
102
|
const { data } = await withSpinner('Updating reference', () => client.references.update(Number(id), data_ as any), format)
|
|
84
103
|
console.log(chalk.green(' Reference updated'))
|
|
85
104
|
output(data, format)
|
|
86
105
|
})
|
|
87
106
|
|
|
107
|
+
refs
|
|
108
|
+
.command('delete <id>')
|
|
109
|
+
.description('Delete a reference')
|
|
110
|
+
.option('--strategy <strategy>', 'Strategy if quotes exist: delete or anonymize')
|
|
111
|
+
.option('--yes', 'Skip confirmation')
|
|
112
|
+
.action(async (id: string, options: Record<string, string>) => {
|
|
113
|
+
if (!options.yes) {
|
|
114
|
+
const { confirm } = await import('@clack/prompts')
|
|
115
|
+
const confirmed = await confirm({ message: `Delete reference #${id}?` })
|
|
116
|
+
if (isCancel(confirmed) || !confirmed) cancel('Cancelled')
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const client = await getClient()
|
|
120
|
+
await withSpinner('Deleting reference', () => client.references.delete(Number(id), options.strategy as 'delete' | 'anonymize' | undefined))
|
|
121
|
+
console.log(chalk.green(` Reference #${id} deleted`))
|
|
122
|
+
})
|
|
123
|
+
|
|
88
124
|
refs
|
|
89
125
|
.command('browse')
|
|
90
126
|
.description('Browse references interactively')
|