import { IHandlerParameters , TextUtils } from "@zowe/imperative" ; import { ListArchivedWorkflows , IWorkflowsInfo , IArchivedWorkflows } from "@zowe/zos-workflows-for-zowe-sdk" ; import { ZosmfBaseHandler } from "@zowe/zosmf-for-zowe-sdk" ; /**
 * Common Handler for listing archived workflows for a system.
 */ export default class ListArchivedWorkflowsHandler extends ZosmfBaseHandler { 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 ListArchivedWorkflows . listArchivedWorkflows ( this . mSession ) ; } catch ( err ) { error = "List workflow(s) " + err ; throw error ; } commandParameters . response . data . setObj ( response ) ; response . archivedWorkflows . forEach ( ( archivedWorkflows ) => { archivedWorkflows . workflowName = TextUtils . wordWrap ( `${ archivedWorkflows . workflowName }` , width ) ; archivedWorkflows . workflowKey = TextUtils . wordWrap ( `${ archivedWorkflows . workflowKey }` , width ) ; } ) ; if ( response . archivedWorkflows . length ) { commandParameters . response . format . output ( { fields : [ "workflowName" , "workflowKey" ] , output : response . archivedWorkflows , format : "table" , header : true } ) ; } else { commandParameters . response . console . log ( "No workflows match the requested query" ) ; } } }