import { IHandlerParameters , TextUtils } from "@zowe/imperative" ; import { IWorkflowsInfo , ListWorkflows , IActiveWorkflows } from "@zowe/zos-workflows-for-zowe-sdk" ; import { ZosmfBaseHandler } from "@zowe/zosmf-for-zowe-sdk" ; /**
 * Common Handler for listing active workflow(s) instance(s) in z/OSMF.
 */ export default class ListActiveWorkflowsHandler extends ZosmfBaseHandler { private type { * } memberof private arguments : any ; param { IHandlerParameters } params returns { Promise < void > } memberof public async processCmd ( commandParameters ) { this . arguments = commandParameters . arguments ; let response ; let error ; const width = 42 ; try { response = await ListWorkflows . getWorkflows ( this . mSession , { workflowName : this . arguments . workflowName , category : this . arguments . category , system : this . arguments . system , owner : this . arguments . owner , vendor : this . arguments . vendor , statusName : this . arguments . statusName } ) ; } catch ( err ) { error = "List workflow(s) " + err ; throw error ; } commandParameters . response . data . setObj ( response ) ; response . workflows . forEach ( ( workflow ) => { workflow . workflowName = TextUtils . wordWrap ( `${ workflow . workflowName }` , width ) ; workflow . workflowKey = TextUtils . wordWrap ( `${ workflow . workflowKey }` , width ) ; workflow . workflowDescription = TextUtils . wordWrap ( `${ workflow . workflowDescription }` , width ) ; } ) ; if ( response . workflows . length ) { commandParameters . response . format . output ( { fields : [ "workflowName" , "workflowKey" , "workflowDescription" ] , output : response . workflows , format : "table" , header : true } ) ; } else { commandParameters . response . console . log ( "No workflows match the requested querry" ) ; } } }