princejwesley / Mancy

>_ Electron based NodeJS REPL :see_no_evil:
http://mancy-re.pl
MIT License
2.63k stars 133 forks source link

[idea] mancy for terminal/console #144

Closed sibelius closed 7 years ago

sibelius commented 8 years ago

Mancy idea is really great

But I would like to use it on terminal instead of an electron app

Maybe we could split Mancy in mancy core that could work on both electron app and with terminal based approach

My current approach to have a node repl running my server is like this

import "reify/repl";
import 'isomorphic-fetch';
import 'babel-polyfill';
import REPL from 'repl';
import replPromised from 'repl-promised';
import * as models from './src/models';

(async() => {
  try {
    const info = await connectDatabase();
    console.log(`Connected to ${info.host}:${info.port}/${info.name}`);

    let repl = REPL.start({
      prompt: 'repl > ',
    });
    repl.context.M = models;
    replPromised.promisify(repl);
  } catch (error) {
    console.error('Unable to connect to database');
    process.exit(1);
  }
})();

Instead of replPromised we could use mancy-core to provide all the awesome features of Mancy

princejwesley commented 8 years ago

@sibelius I am currently interested in making core node REPL better. Here is a proposal

sibelius commented 8 years ago

this would be awesome, but what happens with the older version of node?

can't we try to do both approach?

I don't know if you know ipython (an interactive repl for python)

I think core node REPL should provide the bare minimum, and let other solutions like this one provide extensions

orionlee commented 8 years ago

Or it could be an NPM that ships with core. In that way,

sibelius commented 7 years ago

I think we can extract a preprocess function from Mancy like this: https://gist.github.com/princejwesley/a66d514d86ea174270210561c44b71ba

from here: https://github.com/princejwesley/Mancy/blob/cd0bc938dce89a171b09f0862e22d143c8769eb1/src/common/ReplInput.js#L43

and add one node repl

I'll post here, if I create a package or a repo example using this idea