Skip to content

nopnop/repli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

repli

Minimalist REPL client for node

Installation

npm install -g repli

Usage

  1. Create a repl server somewhere in you application (see exemples/server.js):
'use strict'
const repl = require('repl')
const net = require('net')

net.createServer((socket) => {
  socket.write('Welcome\n')

  let replServer = repl.start({
    prompt: '> ',
    input: socket,
    output: socket,
    terminal: true,
    useGlobal: false
  })

  replServer.on('exit', () => socket.end())

  replServer.context.actions = {
    sayHello (who) {
      console.log('Hello %s !', who || 'World')
      socket.write('(Done)\n')
    }
  }

}).listen(4242)
  1. Then use repli to use it:
repli localhost 4242
> Connect to ip:127.0.0.1 (IPv4)
Welcome
> action.sayHello('Foobar')
(Done)
undefined
> _

Credit

Based on TooTallNate gist


The MIT License

About

Minimalist REPL client for node

Resources

License

Stars

Watchers

Forks

Packages

No packages published