import { IHandlerParameters , TextUtils } from "@zowe/imperative" ; import { ICollectParms , IConsoleResponse , IIssueParms , IssueCommand } from "@zowe/zos-console-for-zowe-sdk" ; import { isNullOrUndefined } from "util" ; import { ZosmfBaseHandler } from "@zowe/zosmf-for-zowe-sdk" ; export class implements ICommandHandler export default class Handler extends ZosmfBaseHandler { public async processCmd ( commandParameters ) { let response ; const issueParms = { command : commandParameters . arguments . commandtext , consoleName : commandParameters . arguments [ "console-name" ] , solicitedKeyword : commandParameters . arguments [ "solicited-keyword" ] , sysplexSystem : commandParameters . arguments [ "sysplex-system" ] , async : commandParameters . arguments [ "key-only" ] === true ? "Y" : "N" } ; if ( isNullOrUndefined ( commandParameters . arguments [ "wait-to-collect" ] ) ) { response = await IssueCommand . issue ( this . mSession , issueParms ) ; } else { const collectParms = { commandResponseKey : "" , consoleName : commandParameters . arguments [ "console-name" ] , waitToCollect : commandParameters . arguments [ "wait-to-collect" ] , followUpAttempts : commandParameters . arguments [ "follow-up-attempts" ] } ; response = await IssueCommand . issueAndCollect ( this . mSession , issueParms , collectParms ) ; } if ( commandParameters . arguments [ "key-only" ] ) { if ( ! isNullOrUndefined ( response . lastResponseKey ) ) { commandParameters . response . console . log ( response . lastResponseKey ) ; } } else { commandParameters . response . console . log ( response . commandResponse ) ; if ( commandParameters . arguments [ "include-details" ] ) { const details = { responseKey : response . lastResponseKey , cmdResponseUrl : response . cmdResponseUrl || undefined , keywordDetected : response . keywordDetected || ( ( ! isNullOrUndefined ( commandParameters . arguments [ "solicited-keyword" ] ) ) ? false : undefined ) } ; commandParameters . response . console . log ( "Additional details:" ) ; commandParameters . response . console . log ( "-------------------" ) ; commandParameters . response . console . log ( TextUtils . prettyJson ( details ) ) ; } } commandParameters . response . data . setObj ( response ) ; } }