Wondering what’s next for npm?Check out our public roadmap! »

    @seneca/repl

    4.0.1 • Public • Published

    Seneca

    A Seneca.js plugin

    seneca-repl

    npm version Build Status Dependency Status Gitter

    Seneca compatibility

    Supports Seneca versions 3.x and higher.

    Install

    To install, simply use npm. Remember you will need to install Seneca.js if you haven't already.

    > npm install seneca
    > npm install @seneca/repl

    Usage

    var Seneca = require('seneca')
     
    var seneca = Seneca()
      // open repl on default port 30303
      .use('repl') 
     
      // open another repl on port 10001
      .use('repl', {port: 10001})
     
      // open yet another repl on a free port chosen by your OS
      // look at the INFO level logs for the host and port
      // or get them from seneca.export('repl/address')
      .use('repl', {port: 0})

    To access the REPL, run the seneca-repl command provided by this module. Install this as a global module for easy access:

    $ npm install -g @seneca/repl
    

    Provide the host (default localhost) and port (default 30303):

    $ seneca-repl remote-host 12345
    

    The seneca-repl command provides a convenient REPL interface including line editing and history. In production settings you'll want to create an SSH tunnel or similar for this purpose.

    Alternatively you can telnet to the port:

    $ telnet localhost 30303
    

    Replace localhost if remote with the address of the remote system.

    For more comfortable experience with working cursor keys, use rlwrap

    $ rlwrap telnet localhost 30303
    

    Commands

    The repl evaluates JavaScript directly. See the Node.js repl docs for more. You also have a seneca instance available:

    seneca x.y.z [seneca-id] -> seneca.toString()
    

    You can submit messages directly using jsonic format:

    seneca x.y.z [seneca-id] -> role:seneca,cmd:stats
    IN  000000: { role: 'seneca', cmd: 'stats' } # ftlbto0vvizm/6qt4gg83fylm cmd:stats,role:seneca (4aybxhxseldu) action_seneca_stats 
    OUT 000000: { start: '2017-03-15T13:15:36.016Z',
      act: { calls: 3, done: 3, fails: 0, cache: 0 },
      actmap: undefined,
      now: '2017-03-15T13:17:15.313Z',
      uptime: 99297 }
    

    The message and response are printed, along with a sequence number. If the Seneca instance is a client of other Seneca services, the message will be sent to the other services, and marked as transported.

    It is often convenient to run a Seneca repl as a separate service, acting as a client to all the other Seneca services. This gives you a central point of control for your system.

    There are some command aliases for common actions:

    • list <pin>: list local patterns, optionally narrowed by pin
    • tree: show local patterns in tree format
    • stats: print local statistics
    • stats full: print full local statistics
    • exit or quit: exit the repl session
    • last: run last command again
    • history: print command history
    • set <path> <value>: set a seneca option, e.g: set debug.deprecation true
    • get <path>: get a seneca option
    • alias <name> <cmd>: define a new alias
    • trace: toggle IN/OUT tracing of submitted messages
    • log: toggle printing of remote log entries in test format (NOTE: these are unfiltered)
    • log match <literal>: when logging is enabled, only print lines matching the provided literal string
    • depth <number>: set depth of Util.inspect printing

    Options

    • test : boolean false

    Set plugin options when loading with:

     
     
    seneca.use('doc', { name: value, ... })
     
     

    Note: foo.bar in the list above means { foo: { bar: ... } }

    Action Patterns

    Action Descriptions

    « add:cmd,sys:repl »

    Add a REPL command dynamically


    Contributing

    The Senecajs org encourages open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.

    Test

    To run tests, simply use npm:

    > npm run test

    License

    Copyright (c) 2015-2020, Richard Rodger and other contributors. Licensed under MIT.

    Install

    npm i @seneca/repl

    DownloadsWeekly Downloads

    20

    Version

    4.0.1

    License

    MIT

    Unpacked Size

    23.5 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar
    • avatar