import { ICommandArguments , ICommandHandler , IHandlerParameters , IProfile , IHandlerResponseConsoleApi , IHandlerFormatOutputApi , IHandlerResponseDataApi , IHandlerProgressApi , IImperativeError , ImperativeError , ConnectionPropsForSessCfg } from "@zowe/imperative" ; import { SshSession } from "./SshSession" ; import { ISshSession } from "./doc/ISshSession" ; /**
 * This class is used by the various handlers in the project as the base class for their implementation.
 */ export abstract class SshBaseHandler implements ICommandHandler { /**
     * The session creating from the command line arguments / profile
     */ protected mSession : SshSession ; /**
     * Loaded z/OS SSH profile if needed
     */ protected mSshProfile : IProfile ; /**
     * Command line arguments passed
     */ protected mArguments : ICommandArguments ; /**
     * Full set of command handler parameters from imperative
     */ protected mHandlerParams : IHandlerParameters ; /**
     * This will grab the arguments and create a session before calling the subclass
     *  SshBaseHandler method.
     *
     *  param { IHandlerParameters } commandParameters returns { Promise < void > } public async process ( commandParameters ) { this . mHandlerParams = commandParameters ; this . mSshProfile = commandParameters . profiles . get ( "ssh" , false ) ; const sshSessCfg = SshSession . createSshSessCfgFromArgs ( commandParameters . arguments ) ; const sshSessCfgWithCreds = await ConnectionPropsForSessCfg . addPropsOrPrompt < ISshSession > ( sshSessCfg , commandParameters . arguments ) ; this . mSession = new SshSession ( sshSessCfgWithCreds ) ; this . mArguments = commandParameters . arguments ; await this . processCmd ( commandParameters ) ; } param { IImperativeError } err public fail ( err ) { throw new ImperativeError ( err ) ; } returns { IHandlerResponseConsoleApi } public get console ( ) : IHandlerResponseConsoleApi { return this . mHandlerParams . response . console ; } returns { IHandlerFormatOutputApi } public get format ( ) : IHandlerFormatOutputApi { return this . mHandlerParams . response . format ; } returns { IHandlerResponseDataApi } public get data ( ) : IHandlerResponseDataApi { return this . mHandlerParams . response . data ; } returns { IHandlerProgressApi } public get progress ( ) : IHandlerProgressApi { return this . mHandlerParams . response . progress ; } /**
     * This is called by the  SshBaseHandler after it creates a session.
     *
     *  param { IHandlerParameters } commandParameters public abstract async processCmd ( commandParameters ) ; }