Browse Source

CLI videos: fix logging, remove output flag

iorveth 4 years ago
parent
commit
7c737c3cd1

+ 9 - 8
cli/src/commands/content/createVideo.ts

@@ -1,13 +1,13 @@
 import ContentDirectoryCommandBase from '../../base/ContentDirectoryCommandBase'
-import { IOFlags, getInputJson, saveOutputJson } from '../../helpers/InputOutput'
+import { IOFlags, getInputJson } from '../../helpers/InputOutput'
 import { videoMetadataFromInput } from '../../helpers/serialization'
 import { VideoCreationParameters, VideoCreationParametersInput } from '../../Types'
 
 export default class CreateVideoCommand extends ContentDirectoryCommandBase {
   static description = 'Create video under specific channel inside content directory.'
   static flags = {
-    context: ContentDirectoryCommandBase.contextFlag,
-    ...IOFlags,
+    context: ContentDirectoryCommandBase.ownerContextFlag,
+    input: IOFlags.input,
   }
 
   static args = [
@@ -19,7 +19,7 @@ export default class CreateVideoCommand extends ContentDirectoryCommandBase {
   ]
 
   async run() {
-    let { context, input, output } = this.parse(CreateVideoCommand).flags
+    let { context, input } = this.parse(CreateVideoCommand).flags
 
     const { channelId } = this.parse(CreateVideoCommand).args
 
@@ -44,11 +44,12 @@ export default class CreateVideoCommand extends ContentDirectoryCommandBase {
         meta,
       }
 
-      this.jsonPrettyPrint(JSON.stringify(videoCreationParameters))
+      this.jsonPrettyPrint(JSON.stringify(videoCreationParametersInput))
+      this.log('Meta: ' + meta)
+
       const confirmed = await this.simplePrompt({ type: 'confirm', message: 'Do you confirm the provided input?' })
 
-      if (confirmed && videoCreationParametersInput) {
-        saveOutputJson(output, `${videoCreationParametersInput.meta.title}Video.json`, videoCreationParametersInput)
+      if (confirmed) {
         this.log('Sending the extrinsic...')
 
         await this.sendAndFollowNamedTx(currentAccount, 'content', 'createVideo', [
@@ -58,7 +59,7 @@ export default class CreateVideoCommand extends ContentDirectoryCommandBase {
         ])
       }
     } else {
-      this.log('Input invalid or was not provided...')
+      this.error('Input invalid or was not provided...')
     }
   }
 }

+ 0 - 1
cli/src/commands/content/updateChannel.ts

@@ -49,7 +49,6 @@ export default class UpdateChannelCommand extends ContentDirectoryCommandBase {
 
       this.log('Meta: ' + meta)
 
-      this.jsonPrettyPrint(JSON.stringify(channelUpdateParameters))
       const confirmed = await this.simplePrompt({ type: 'confirm', message: 'Do you confirm the provided input?' })
 
       if (confirmed) {

+ 9 - 8
cli/src/commands/content/updateVideo.ts

@@ -1,13 +1,13 @@
 import ContentDirectoryCommandBase from '../../base/ContentDirectoryCommandBase'
-import { IOFlags, getInputJson, saveOutputJson } from '../../helpers/InputOutput'
+import { IOFlags, getInputJson } from '../../helpers/InputOutput'
 import { VideoUpdateParameters, VideoUpdateParametersInput } from '../../Types'
 import { videoMetadataFromInput } from '../../helpers/serialization'
 
 export default class UpdateVideoCommand extends ContentDirectoryCommandBase {
   static description = 'Update video under specific id.'
   static flags = {
-    context: ContentDirectoryCommandBase.contextFlag,
-    ...IOFlags,
+    context: ContentDirectoryCommandBase.ownerContextFlag,
+    input: IOFlags.input,
   }
 
   static args = [
@@ -19,7 +19,7 @@ export default class UpdateVideoCommand extends ContentDirectoryCommandBase {
   ]
 
   async run() {
-    let { context, input, output } = this.parse(UpdateVideoCommand).flags
+    let { context, input } = this.parse(UpdateVideoCommand).flags
 
     const { videoId } = this.parse(UpdateVideoCommand).args
 
@@ -44,11 +44,12 @@ export default class UpdateVideoCommand extends ContentDirectoryCommandBase {
         meta,
       }
 
-      this.jsonPrettyPrint(JSON.stringify(videoUpdateParameters))
+      this.jsonPrettyPrint(JSON.stringify(videoUpdateParametersInput))
+      this.log('Meta: ' + meta)
+
       const confirmed = await this.simplePrompt({ type: 'confirm', message: 'Do you confirm the provided input?' })
 
-      if (confirmed && videoUpdateParametersInput) {
-        saveOutputJson(output, `${videoUpdateParametersInput.meta.title}Video.json`, videoUpdateParametersInput)
+      if (confirmed) {
         this.log('Sending the extrinsic...')
 
         await this.sendAndFollowNamedTx(currentAccount, 'content', 'updateVideo', [
@@ -58,7 +59,7 @@ export default class UpdateVideoCommand extends ContentDirectoryCommandBase {
         ])
       }
     } else {
-      this.log('Input invalid or was not provided...')
+      this.error('Input invalid or was not provided...')
     }
   }
 }