import { AbstractSession , IHandlerParameters , ITaskWithStatus , TaskStage , TextUtils } from "@zowe/imperative" ; import { IZosFilesResponse , Upload } from "@zowe/zos-files-for-zowe-sdk" ; import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler" ; import { Readable } from "stream" ; export export default class StdinToDataSetHandler extends ZosFilesBaseHandler { public async processWithSession ( commandParameters , session ) { const task = { percentComplete : 0 , statusMessage : "Uploading stdin to data set" , stageName : TaskStage . IN_PROGRESS } ; commandParameters . response . progress . startBar ( { task } ) ; const result = await Upload . streamToDataSet ( session , process . stdin as unknown as Readable , commandParameters . arguments . dataSetName , { volume : commandParameters . arguments . volumeSerial , binary : commandParameters . arguments . binary , task , responseTimeout : commandParameters . arguments . responseTimeout } ) ; if ( result . success ) { const formatMessage = TextUtils . prettyJson ( { success : result . success , from : "stdin" , to : commandParameters . arguments . dataSetName } ) ; commandParameters . response . console . log ( formatMessage ) ; } return result ; } }