### Table of Contents - [Path](#path) - [exists](#exists) - [isExistingFile](#isexistingfile) - [isExistingDirectory](#isexistingdirectory) - [isDirectory](#isdirectory) - [getCurrentWorkingDirectory](#getcurrentworkingdirectory) - [getAbsolutePath](#getabsolutepath) - [getRelativePath](#getrelativepath) - [getBaseName](#getbasename) - [getDirectory](#getdirectory) - [equals](#equals) - [PathAutocomplete](#pathautocomplete) - [reset](#reset) - [getPath](#getpath) - [getActivePath](#getactivepath) - [isDirectoryOnly](#isdirectoryonly) - [getMatches](#getmatches) - [getMatchIndex](#getmatchindex) - [getWorkingDirectory](#getworkingdirectory) - [setPath](#setpath) - [cancelMatch](#cancelmatch) - [selectMatch](#selectmatch) - [nextMatch](#nextmatch) - [refreshMatches](#refreshmatches) - [findMatches](#findmatches) - [PathPrompt](#pathprompt) - [\_run](#_run) - [onKeyPress](#onkeypress) - [onEnterPressed](#onenterpressed) - [onEscapePressed](#onescapepressed) - [onExit](#onexit) - [submitAnswer](#submitanswer) - [restoreEventHandlers](#restoreeventhandlers) - [PathPromptRenderer](#pathpromptrenderer) - [kill](#kill) - [render](#render) - [renderNewPrompt](#rendernewprompt) - [renderError](#rendererror) - [buildMainContent](#buildmaincontent) - [buildBottomContent](#buildbottomcontent) - [resetCursor](#resetcursor) - [shortenArray](#shortenarray) ## Path A system path that may or may not exist. If the path points to a directory, it should end with path.sep. **Parameters** - `cwd` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Path](#path))** The working directory from which the path should be resolved. - `relativePath` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The path relative to the current working directory. ### exists Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the path exists ### isExistingFile Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the path is an existing file ### isExistingDirectory Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the path is an existing directory ### isDirectory Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the relative path ends with path.sep or it is not present at all ### getCurrentWorkingDirectory Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The current working directory path from which the relative path is resolved. ### getAbsolutePath Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The absolute path of this instance ### getRelativePath Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The relative path of this instance ### getBaseName Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The base name of the current path ### getDirectory Returns **[Path](#path)** The directory containing this path ### equals **Parameters** - `p` **[Path](#path)?** The compared path Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the paths are equal ## PathAutocomplete State machine for a path autocomplete UI. **Parameters** - `cwd` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The working directory from which path should be resolved - `directoryOnly` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If set to should handle only directories (optional, default `false`) ### reset Reset the state of the class Returns **void** ### getPath Returns **[Path](#path)** The current input path ### getActivePath Returns **[Path](#path)** The currently selected path or the path ### isDirectoryOnly Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the autocomplete is for directory only ### getMatches Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Path](#path)>?** The current matches ### getMatchIndex Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The current match index or -1 if no match is selected; ### getWorkingDirectory Returns **[Path](#path)** The current working directory ### setPath Set the path based on the user input **Parameters** - `input` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Returns **void** ### cancelMatch Reset the matches/match index Returns **void** ### selectMatch Use the current match index (or the provided one) to update the current path **Parameters** - `matchIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** (optional, default `this.matchSelectionIndex`) Returns **void** ### nextMatch Go to the next potential path. If there is only one match, the current path is set to that match. **Parameters** - `forward` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, move to the next match. Otherwise move to the previous match. Returns **void** ### refreshMatches Refresh the matches for the current path. NOOP if the matches have already been computed ### findMatches Find a list of existing file system files or directory matching the current input path. If multiple files/directories share the same prefix, a single entry with the shared prefix is returned. Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Path](#path)>?** ## PathPrompt **Extends BasePrompt** An Inquirer prompt for a one or more file system path. It supports autocompletion similarly to zshell. **Parameters** - `question` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** - `question.name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name to use when storing the answer in the answers hash. - `question.message` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The message to display when prompting the user for a path. - `question.cwd` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The default working directory from which relative paths are resolved. It is also the default value. (optional, default `process.cwd()`) - `question.default` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Same as question.cwd (optional, default `process.cwd()`) - `question.multi` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If set to true, the user can enter multiple paths (optional, default `false`) - `question.directoryOnly` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If set to true, the user can only enter paths to directories (optional, default `false`) - `question.validate` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)?** Receive the user input and should return true if the value is valid or an error message (String) otherwise. If false is returned, a default error message is provided. If question.multi is true, it is called for each path entered by the user. - `question.validateMulti` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)?** If question.multi is set to true, it is called once the question has been answered. It should return true if the value is valid or an error message (String) otherwise. - `question.filter` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)?** Receive the user input and return the filtered value to be used inside the program. The value returned will be added to the Answers hash. - `question.when` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)?** Receive the current user answers hash and should return true or false depending on whether or not this question should be asked. The value can also be a simple boolean.. - `rl` **ReadLineInterface** An instance of readline.Interface - `answers` **{}** The answers provided by the user to other prompts ### \_run Runs the path prompt. **Parameters** - `callback` **function (value: ([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>)): void** Called when the prompt has been answered successfully Returns **[PathPrompt](#pathprompt)** ### onKeyPress Handle the keyPress events and update the @{link PathAutocomplete} state accordingly. **Parameters** - `value` **KeyPressEvent$Value** The string value of the keyboard entry - `key` **KeyPressEvent$Key** Information about the name of the key and whether other special keys were pressed at the same time. ### onEnterPressed Select the current match or submit the answer ### onEscapePressed Cancel matching or submit the answer for a multi path prompt ### onExit Event handler for cancel events (SIGINT). If the user is currently selecting a path, it causes the selection to be cancelled. If the prompt is a multi path prompt, it causes the question to be done. If none of these conditions are met, the event handlers are cleaned up and the regular SIGINT handlers are involved **Parameters** - `args` **...[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<any>** ### submitAnswer Validate the answer and kill the prompt if it's either a single path prompt or a multiple path prompt and submitMulti is set to true. **Parameters** - `submitMulti` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If set to true, submit all answers ### restoreEventHandlers Unregister the instance's event handlers and register global event handlers ones that were temporarily removed. ## PathPromptRenderer Render the path prompt UI based on a instance of { @link PathAutocomplete } **Parameters** - `rl` **ReadLineInterface** - `screen` **ScreenManager** - `autocomplete` **[PathAutocomplete](#pathautocomplete)** - `message` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** ### kill Restore the state of the resources used by the renderer Returns **void** ### render Render the prompt UI **Parameters** - `finalAnswer` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** If present, display the final answer (optional, default `null`) Returns **void** ### renderNewPrompt Render the UI for a new prompt. It finalizes the current render, inserts a new line and render a new path prompt. **Parameters** - `finalAnswer` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** - `autocomplete` **[PathAutocomplete](#pathautocomplete)** The new autocomplete state instance ### renderError Render the error UI **Parameters** - `error` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Returns **void** ### buildMainContent Render the main content of the prompt. The message includes the question and the current response. **Parameters** - `finalAnswer` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** If present, display the final answer (optional, default `null`) Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** ### buildBottomContent Render the bottom content of the prompt. It displays the current selection state of the [PathAutocomplete](#pathautocomplete) instance Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** ### resetCursor Reset the input cursor to the end of the line Returns **void** ### shortenArray Slice an array around a specific item so that it contains a specific number of elements. **Parameters** - `items` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<T>** The array to shorten - `itemIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The index of the item that should be included in the returned slice - `size` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The desired size of the array to be returned Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<T>**