@zowe/cli
Version:
Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.
120 lines • 6.4 kB
TypeScript
import { IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk";
import { AbstractSession, IHandlerParameters } from "@zowe/imperative";
/**
* enum of prompts to be used as input to {@link EditUtilities.promptUser} during the file editing process
* @export
* @enum
*/
export declare enum Prompt {
useStash = 0,
viewDiff = 1,
overwriteRemote = 2,
viewUpdatedRemote = 3,
continueToUpload = 4
}
/**
* Type indicates which file system is being used for storage on mainframe {@link ILocalFile}
* @export
* @type
*/
export type EditFileType = "uss" | "ds";
/**
* A class to hold pertinent information about the local file during the editing process
* @export
* @interface
*/
export interface ILocalFile {
tempPath: string | null;
fileName: string;
fileType: EditFileType;
guiAvail: boolean;
zosResp: IZosFilesResponse | null;
conflict: boolean;
encoding?: string | null;
binary?: boolean;
}
/**
* A shared utility class that uss and ds handlers use for local file editing
* @export
* @class
*/
export declare class EditUtilities {
/**
* Builds a temp path where local file will be saved. If uss file, file name will be hashed
* to prevent any conflicts with file naming. A given filename will always result in the
* same unique file path.
* @param {ILocalFile} lfFile - object containing pertinent information about the local file during the editing process
* @returns {Promise<string>} - returns unique file path for temp file
* @memberof EditUtilities
*/
static buildTempPath(lfFile: ILocalFile, commandParameters: IHandlerParameters): Promise<string>;
/**
* Check for temp path's existence (check if previously 'stashed'/temp edits exist)
* @param {string} tempPath - unique file path for local file (stash/temp file)
* @returns {Promise<boolean>} - promise that resolves to true if stash exists or false if doesn't
* @memberof EditUtilities
*/
static checkForStash(tempPath: string): Promise<boolean>;
/**
* Collection of prompts to be used at different points in editing process
* @param {Prompt} prompt - selected prompt from {@link Prompt} (enum object)
* @param {Boolean} conflict - optional. true if detected conflict between local and remote files
* @returns {Promise<boolean>} - promise whose resolution depends on user input
* @memberof EditUtilities
*/
static promptUser(prompt: Prompt, conflict?: boolean): Promise<boolean>;
/**
* Download file and determine if downloading just to get etag (useStash) or to save file locally & get etag (!useStash)
* @param {AbstractSession} session - the session object generated from the connected profile
* @param {ILocalFile} lfFile - object containing pertinent information about the local file during the editing process
* @param {boolean} useStash - should be true if don't want to overwrite local file when refreshing etag
* @returns {ILocalFile}
*/
static localDownload(session: AbstractSession, lfFile: ILocalFile, useStash: boolean): Promise<ILocalFile>;
/**
* Performs appropriate file comparison (either in browser or as a terminal diff) between local file and remote
* Local file (lf) will then be opened in default editor
* @param {AbstractSession} session - the session object generated from the connected profile
* @param {IHandlerParameters} commandParameters - parameters supplied by args
* @param {ILocalFile} lfFile - object containing pertinent information about the local file during the editing process
* @param {boolean} promptUser - optional. if there are changes then prompt user to show diff, otherwise return
* @returns {Promise<IZosFilesResponse>} - the response generated by {@link CompareBaseHelper.getResponse}
* @memberof EditUtilities
*/
static fileComparison(session: AbstractSession, commandParameters: IHandlerParameters, lfFile: ILocalFile, promptUser?: boolean): Promise<IZosFilesResponse>;
/**
* Enable user to make their edits and wait for user input to indicate editing is complete
* @param {ILocalFile} lfFile - object containing pertinent information about the local file during the editing process
* @param {string} editor - optional parameter originally supplied by args
* @memberof EditUtilities
*/
static makeEdits(lfFile: ILocalFile, editor?: string): Promise<boolean>;
/**
* Upload temp file with saved etag
* - if matching etag: successful upload, destroy stash/temp -> END
* - if non-matching etag: unsuccessful upload -> refresh etag -> perform file comparison/edit -> re-attempt upload
* @param {AbstractSession} session - the session object generated from the connected profile
* @param {IHandlerParameters} commandParameters - parameters supplied by args
* @param {ILocalFile} lfFile - object containing pertinent information about the local file during the editing process
* @returns {Promise<[boolean, boolean]>} - [resolves to true if uploading was successful and
* false if not, resolves to true if user wishes to cancel command and false if not]
* @memberof EditUtilities
*/
static uploadEdits(session: AbstractSession, commandParameters: IHandlerParameters, lfFile: ILocalFile): Promise<[boolean, boolean]>;
/**
* When changes occur in the remote file, user will have to overwrite remote or account for the discrepancy between files
* @param {AbstractSession} session - the session object generated from the connected profile
* @param {IHandlerParameters} commandParameters - parameters supplied by args
* @param {ILocalFile} lfFile - object containing pertinent information about the local file during the editing process
* @returns {Promise<boolean>} - returns a boolean where true means command is canceled and false means continue
* @memberof EditUtilities
*/
static etagMismatch(session: AbstractSession, commandParameters: IHandlerParameters, lfFile: ILocalFile): Promise<[boolean, boolean]>;
/**
* Destroy path of temporary local file (remove stash)
* @param {string} tempPath - unique file path for local file (stash)
* @memberof EditUtilities
*/
static destroyTempFile(tempPath: string): Promise<void>;
}
//# sourceMappingURL=Edit.utils.d.ts.map