UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

52 lines (51 loc) 3.06 kB
import * as readline from 'readline'; import type { ReplOutput } from './commands/repl-main'; import type { MergeableRecord } from '../../util/objects'; import type { KnownParser } from '../../r-bridge/parser'; /** * Used by the repl to provide automatic completions for a given (partial) input line */ export declare function replCompleter(line: string): [string[], string]; export declare function makeDefaultReplReadline(): readline.ReadLineOptions; /** * This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics). * * @param output - Defines two methods that every function in the repl uses to output its data. * @param expr - The expression to process. * @param parser - The {@link RShell} or {@link TreeSitterExecutor} to use (see {@link repl}). * @param allowRSessionAccess - If true, allows the execution of arbitrary R code. */ export declare function replProcessAnswer(output: ReplOutput, expr: string, parser: KnownParser, allowRSessionAccess: boolean): Promise<void>; /** * Options for the {@link repl} function. */ export interface FlowrReplOptions extends MergeableRecord { /** The shell to use, if you do not pass one it will automatically create a new one with the `revive` option set to 'always'. */ readonly parser?: KnownParser; /** * A potentially customized readline interface to be used for the repl to *read* from the user, we write the output with the {@link ReplOutput | `output` } interface. * If you want to provide a custom one but use the same `completer`, refer to {@link replCompleter}. * For the default arguments, see {@link DEFAULT_REPL_READLINE_CONFIGURATION}. */ readonly rl?: readline.Interface; /** Defines two methods that every function in the repl uses to output its data. */ readonly output?: ReplOutput; /** The file to use for persisting the repl's history. Passing undefined causes history not to be saved. */ readonly historyFile?: string; /** If true, allows the execution of arbitrary R code. This is a security risk, as it allows the execution of arbitrary R code. */ readonly allowRSessionAccess?: boolean; } /** * Provides a never-ending repl (read-evaluate-print loop) processor that can be used to interact with a {@link RShell} as well as all flowR scripts. * * The repl allows for two kinds of inputs: * - Starting with a colon `:`, indicating a command (probe `:help`, and refer to {@link commands}) </li> * - Starting with anything else, indicating default R code to be directly executed. If you kill the underlying shell, that is on you! </li> * * @param options - The options for the repl. See {@link FlowrReplOptions} for more information. * * For the execution, this function makes use of {@link replProcessAnswer}. * */ export declare function repl({ parser, rl, output, historyFile, allowRSessionAccess }: FlowrReplOptions): Promise<void>; export declare function loadReplHistory(historyFile: string): string[] | undefined;