Options
All
  • Public
  • Public/Protected
  • All
Menu

Class export=

Hierarchy

  • export=

Index

Constructors

  • new export=(options: options): export=
  • create a new repl

    example
    const creply = require("creply");
    const repl = new creply({
    name: "app",
    version: "1.0.0",
    description: "my repl",
    history: "./history.txt",
    prefix: "!",
    prompt: "> "
    });

    Parameters

    • options: options

      the creply options

    Returns export=

Properties

commands: command

all the commands created by the creply.addCommand method

Accessors

  • get readline(): readline
  • the readline used by creply

    example
    repl.readline // will return the readline used by creply
    

    Returns readline

  • get rl(): Interface
  • the readline interface used by creply first start the repl to get the readline interface

    Returns Interface

Methods

  • addCommand(name: string, options: addCommandOptions): void
  • adds a command

    example
    repl.addCommand("say", {
    description: "says something",
    exec: (args) => {
    console.log(args);
    },
    usage: () => {
    return "say <something>";
    }
    });

    Parameters

    • name: string

      the name of the command

    • options: addCommandOptions

    Returns void

  • clear(): void
  • clears the screen

    example
    repl.clear() // will clear the screen
    

    Returns void

  • eval(line: string): void
  • evals the repl input line

    example
    repl.eval("!help") // will eval the command "help"
    

    Parameters

    • line: string

    Returns void

  • exit(): void
  • exits the repl

    example
    repl.exit() // will exit the repl
    

    Returns void

  • get(name: optionsNames): any
  • get a option

    example
    repl.get("prompt") // will return the prompt
    

    Parameters

    • name: optionsNames

      the name of the option

    Returns any

    the value of the option

  • handler(): void
  • handle things like:

    • on process exit
    • on error if an error is thrown and the error comes with process.exit() the repl will exit

    Returns void

  • help(): void
  • prints the help

    example
    repl.help() // will print the help
    

    Returns void

  • interface(history: string): Promise<string>
  • the readline.Interface instance

    Parameters

    • history: string

      history file

    Returns Promise<string>

  • log(...data: any[]): void
  • Parameters

    • Rest ...data: any[]

    Returns void

  • on(eventName: events, listener: any): void
  • example
    repl.on("line",(line) => {
    console.log("Hello "+line);
    });

    Parameters

    • eventName: events
    • listener: any

    Returns void

  • removeCommand(name: string): void
  • remove a command

    example
    repl.removeCommand("say") // will remove the command "say"
    

    Parameters

    • name: string

      the name of the command to remove

    Returns void

  • set(keys: Partial<options>): void
  • set a option

    example
    repl.set({
    prompt: "> ",
    name: "my-repl",
    version: "1.0.0",
    description: "my description"
    });

    Parameters

    • keys: Partial<options>

    Returns void

  • start(): Promise<void>
  • starts the repl

    example
    repl.start() // will start the repl
    

    Returns Promise<void>

  • usage(command: string): void
  • show usage of a command only works with user commands

    example
    repl.usage("say") // will show the usage of the command "say"
    

    Parameters

    • command: string

      the name of the command

    Returns void

Generated using TypeDoc