|
@@ -5,11 +5,13 @@ import { InputParser } from 'cd-schemas'
|
|
|
import { IOFlags, getInputJson, saveOutputJson } from '../../helpers/InputOutput'
|
|
|
import { JSONSchema } from '@apidevtools/json-schema-ref-parser'
|
|
|
import { JsonSchemaCustomPrompts, JsonSchemaPrompter } from '../../helpers/JsonSchemaPrompt'
|
|
|
+import { flags } from '@oclif/command'
|
|
|
|
|
|
export default class CreateChannelCommand extends ContentDirectoryCommandBase {
|
|
|
static description = 'Create a new channel on Joystream (requires a membership).'
|
|
|
static flags = {
|
|
|
...IOFlags,
|
|
|
+ confirm: flags.boolean({ char: 'y', name: 'confirm', required: false, description: 'Confirm the provided input' }),
|
|
|
}
|
|
|
|
|
|
async run() {
|
|
@@ -21,7 +23,7 @@ export default class CreateChannelCommand extends ContentDirectoryCommandBase {
|
|
|
|
|
|
const channelJsonSchema = (ChannelEntitySchema as unknown) as JSONSchema
|
|
|
|
|
|
- const { input, output } = this.parse(CreateChannelCommand).flags
|
|
|
+ const { input, output, confirm } = this.parse(CreateChannelCommand).flags
|
|
|
|
|
|
let inputJson = await getInputJson<ChannelEntity>(input, channelJsonSchema)
|
|
|
if (!inputJson) {
|
|
@@ -36,7 +38,8 @@ export default class CreateChannelCommand extends ContentDirectoryCommandBase {
|
|
|
}
|
|
|
|
|
|
this.jsonPrettyPrint(JSON.stringify(inputJson))
|
|
|
- const confirmed = await this.simplePrompt({ type: 'confirm', message: 'Do you confirm the provided input?' })
|
|
|
+ const confirmed =
|
|
|
+ confirm || (await this.simplePrompt({ type: 'confirm', message: 'Do you confirm the provided input?' }))
|
|
|
|
|
|
if (confirmed) {
|
|
|
saveOutputJson(output, `${inputJson.title}Channel.json`, inputJson)
|