Giter Site home page Giter Site logo

nesh's Introduction

nesh's People

Contributors

ccheever avatar dalejung avatar danielgtaylor avatar forivall avatar jawj avatar mklement0 avatar rgbkrk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nesh's Issues

Cryptic error when loading a module with babel

$ cat ./src/storage.js 

export const sqrt = Math.sqrt;
export function square(x) {
    return x * x;
}
export function diag(x, y) {
    return sqrt(square(x) + square(y));
}

OK this is a pretty basic object. I'll try to import it:

~/projects/StarsApp @ Magni (jcollum) 
$ nesh -b
Babel 5.8.38 on Node v7.8.0
Type .help for more information
babel> import './src/storage';
TypeError: Cannot read property 'error' of undefined
    at OptionManager.mergeOptions (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126:28)
    at OptionManager.addConfig (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/transformation/file/options/option-manager.js:107:10)
    at OptionManager.findConfigs (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/transformation/file/options/option-manager.js:168:35)
    at OptionManager.init (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:12)
    at compile (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/api/register/node.js:117:22)
    at normalLoader (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/api/register/node.js:199:14)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/api/register/node.js:216:7)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

Key line:

TypeError: Cannot read property 'error' of undefined at OptionManager.mergeOptions (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126:28)

I'm not sure what I'm doing wrong. The error isn't much help.

Some REPL commands have an extra dot in front of them

See #36. I think this has been around for a while.

.cls .history and .versions need double dots in front of them for some reason.

nesh*> .help
.cls    Clear the screen
.history    Show command history
.versions   Show Node version information
break   Sometimes you get stuck, this gets you out
clear   Alias for .break
doc Shows documentation for an expression; you can also type Ctrl-Q in-line
exit    Exit the repl
help    Show repl options
load    Load JS from a file into the REPL session
require Require a module and assign it to a variable with the same name
save    Save all evaluated commands in this REPL session to a file
nesh*>

Errors swallowed when using --eval

I've been trying to use nesh to give me a dev console for an express.js web app (like rails console).

I pass the web app code to nesh with --eval, but I find that all error messages are swallowed, which makes this hopeless for debugging.

I'm actually using -c for CoffeeScript, but the problem seems to be unrelated, since this simple test case illustrates the problem:

$ nesh --eval 'xyz(xyz)'
Node v0.10.32
Type .help for more information
nesh> undefined

If I instead use .load manually, things work as expected:

nesh> .load /Users/George/Downloads/xyz.js
nesh> // Generated by CoffeeScript 1.8.0
undefined
nesh> xyz(xyz);
ReferenceError: xyz is not defined
    at repl:1:5
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:814:20)
    at Interface.write (readline.js:294:24)
nesh> //# sourceMappingURL=xyz.js.map
undefined
nesh> 

I've dug around the source code (and especially the eval plugin) for a while but not had any luck working out how to fix this. Presumably it has something to do with vm.runInContext and the like?

Suggestion: Implement a 'nesh profile' feature.

An invaluable feature of nesh is the ability to preload code into the REPL.

I've used this to set up a poor man's profile feature to preload a 'nesh profile' file into my nesh REPLs via aliases placed in my shell profile:

   # CoffeeScript REPL
alias neshc='nesh -c -e ~/.nesh_profile.coffee'
  # JavaScript REPL
alias neshj='nesh -e <(coffee -bp ~/.nesh_profile.coffee)'

A drawback of this approach is that I cannot load additional code in an ad-hoc fashion by providing an additional -e option instance on the command line (this may be worth addressing separately: mixing files and strings with multiple -e instances currently doesn't work; with -c even multiple string-only -e instances break).

For convenience it would be great if nesh - analogous to shells and their profiles - preloaded such a file - required to have a prescribed name and location; e.g., ~/.nesh_profile.coffee - automatically.
In cases where preloading is not desired, an option --noprofile (analogous to bash) could suppress it.

I suspect I could roll this feature myself with a plugin, but I wonder if it's of appeal to enough people to warrant making it part of nesh itself.

Windows 7 - problems with nesh executable

I have some problems with the nesh executable on Win 7. I am new to nodejs and therefore I don't know exactly if that is related to the nesh module. Anyway, after global install with "npm install -g nesh" the executable cannot be launched and the error in the attached image pops up. I looked in the nodejs folder and the nesh.cmd is there next to node.cmd and coffee.cmd (which work on the shell).
image

Optionally watch preloaded code

If I preload a file, it’d be nice if the file could be re-evaluated every time it changes. This is similar to auto-reloading modules, but slightly different. It should be easy to implement and would be tremendously useful for combining a text editor with nesh as a REPL.

how to make local values available when embedding?

Hi,

I'm trying to embed a coffeescript REPL inside a coffeescript program. I've constructed a carefully-configured object that I'd like to pass into the REPL, which cannot easily be constructed by an eval'ed string.

Is there something like this available?

opts.locals=
myobj: carefully_constructed_obj

Or how do I add something to nesh.defaults?

-G

nesh crashes when tab completing at certain place

It's always reproducible on my machine. I tried to reproduce it with other code but failed. Currently the exact reproducible code is:

function construct(f) {
let newObject = Object.create(f.prototype);
newO

The nesh will crash when you press tab key right after the "newO". Here's the screenshot:

image

License?

Are you able to add a license to nesh?

Debugger / --inspect ?

I was hoping to switch my default usage from babel-node to nesh for the extra functionality, but from a quick skim I can't see if/how starting with the debugger is supported?

My current workflow is: babel-node --inspect, and then I can connect to it from the chrome debugger.

Is there an equivalent feature (either core or plugin) with nesh?

My current (seemingly ineffective) attempt: npx nesh -b --inspect

coffeescript repl inserts a special character when entering multiline

coffeescript repl inserts special character when I press ctrl+v or ctrl+shift+v. I am trying to eval the source that is entered on the prompt. how can i remove this character or avoid this.

nesh = require 'nesh'
require 'sugar'
CoffeeScript = require 'coffee-script'
opts = 
    welcome: 'Welcome Coffee!!'
    prompt: '>'
    eval: (cmd, context, filename, cb) ->
        newContext = vm.createContext(context)
        try
        js = CoffeeScript.compile( cmd, bare: true)
        res = vm.runInThisContext js, filename
        console.log res
    catch err then return cb console.log err        
nesh.config.load()
nesh.loadLanguage('coffee')
nesh.start opts, (err)->
    nesh.log.error(err) if err

and on running this ..with ctrl+v or ctrl+shift+v

c:\wn>coffee nesh_try.coffee
Welcome Coffee!!
---->hello = ->
.....  console.log 'hello'
{ [SyntaxError: unexpected ?]
  location: { first_line: 0, first_column: 35, last_line: 0, last_column: 35 },
  toString: [Function],
  code: '(hello = ->  ?  console.log \'hello\'?\n)',
  filename: undefined }
undefined

Using nesh formatting inside callbacks

Hi! This project has been very helpful, thank you very much.
I have a question about the pretty print usage.
I've noticed how nesh automatically pretty prints any value evaluated in an expression; however, most of the times I want to pretty print a value returned from a database, which is not the returned/evaluated expression. How would I do that?

prettyprint

The first example is what I want (pretty print), in the second, is there any method I can use instead of console.log to use the same pretty output?

Thanks!

nesh REPL commands failing, maybe due to issue #6 ?

Hi,
Was really looking forward to using the .history command in nesh, but no joy:

me@there:~/me$ nesh --prompt "foo> " -e ./setup.js 
Node v0.12.7
Type .help for more information
foo> var bar = require('shelljs/global');
undefined
foo> .history
Invalid REPL keyword
undefined
foo> .hist
Invalid REPL keyword
undefined
foo> history
ReferenceError: history is not defined
...

If this is related to issue #6 feel free to comment and close this as a dupe.
Danke,

minimal_o

Repeated reverse-i-search cause bad newlines on short terminal

If I search back through my history and the line length is too long, it wraps around and isn't correctly replaced by the next search result. e.g. (typing Sync):

(reverse-i-search)`S': Sync(function(){monitoring.configurePagerduty('my-service
(reverse-i-search)`Sy': Sync(function(){monitoring.configurePagerduty('my-servic
(reverse-i-search)`Syn': Sync(function(){monitoring.configurePagerduty('my-servi
(reverse-i-search)`Sync': Sync(function(){monitoring.configurePagerduty('my-service', '[email protected]')})

Exit nesh without terminating the process

Is there a way to exit embeded nesh REPL without terminating the process?

If so, is there a way handle exit event like with node's original REPL?

I'd like a way to quickly embed nesh in my mocha based test cases to inspect what is going on when they fail. Unfortunately when I .exit, the whole process stops. It's bad mainly because after and afterEach hooks don't get called.

This is possibly related to #19

Process for proposing plugins for inclusion by default?

Is there any process for proposing plugins be included with nesh by default?

In particular, I use this one in almost every session:
https://github.com/ccheever/nesh-require
and since it just adds another REPL keyword that shouldn't bother you if you don't use it, it seems like there wouldn't be too much downside in including it.

It's just shorthand for requiring modules.
Ex.

nesh> .require app-modules/ntconfig
ntconfig = require("app-modules/ntconfig")
nesh> .require http
http = require("http")
nesh> http

Just wanted to float the idea. I can put more effort into documenting and shoring up the module if there's interest.

can't use global with nesh

I don't know if this is a problem with nesh, or user error, but when I start nesh with the option useGlobal: true (which is one of the options for repl) it doesn't work any more. Here is my test code:

 nesh = require 'nesh' 
opts = welcome: 'Howdy!', prompt: 'nesh> ', useGlobal: true
nesh.loadLanguage 'coffee'
nesh.start opts, (err) ->
  nesh.log.error err if err

And here is my output:

16:59 ~/code/play $ coffee neshtest.coffee
Howdy!
nesh> x=2
TypeError: needs a 'context' argument.
at REPLServer.replDefaults.eval (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/repl.js:33:28)
at repl.js:239:12
at Interface. (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/repl.js:62:9)
at Interface.EventEmitter.emit (events.js:117:20)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:754:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:117:20)
at emitKey (readline.js:1089:12)
at ReadStream.onData (readline.js:834:14)
at ReadStream.EventEmitter.emit (events.js:95:17)
at ReadStream. (stream_readable.js:720:14)
at ReadStream.EventEmitter.emit (events.js:92:17)
at emitReadable
(_stream_readable.js:392:10)
at emitReadable (_stream_readable.js:388:5)
at readableAddChunk (_stream_readable.js:150:9)
at ReadStream.Readable.push (_stream_readable.js:113:10)
at TTY.onread (net.js:511:21)

nesh>

What I am trying to do is run nesh with the same context as the main program so I can interact with the objects in node through nesh just like I would interact with ActiveRecord objects through the rails console. Is this possible? What am I doing wrong?

wished feature: multi line editing in history

I understand current implementation of history is by lines only; same as in bash or python REPL; but came from python world, I usually use ipython (which is a 3rd party pip package) instead of the default python shell that provides additional features like history persistence, and this nice feature: multi lines editing in history

if node doesn't want to improve its default REPL shell line editing experience, I would wish this nice feature can be done by some 3rd party project like this Node Enhanced Shell, or by a plugin

➸ ~/.local/bin/ipython
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
Type "copyright", "credits" or "license" for more information.

IPython 4.1.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: def fibonacci(n):
   ...:     a, b = 1, 1
   ...:     while a < n:
   ...:         a, b = a+b, a
   ...:     return a
   ...: 

In [2]: fibonacci(3)
Out[2]: 3

In [3]: fibonacci(4)
Out[3]: 5

In [4]: fibonacci(18)
Out[4]: 21

In [5]: def fibonacci(n):                  <= here is brought by arrow up key, it can find back multi lines for editing
    a, b = 1, 1
    while a < n:
        a, b = a+b, a
    return a

Using with Meteor question

Hey Daniel,
I was looking for a way to embed a coffee REPL into a Meteor application, and found out about nesh. Is it possible to use nesh as a REPL to the server while Meteor is running? Do you know if there is a package for that? If you don't know about Meteor in particular, is it possible to take a Node application in general and embed the REPL in it in order to interact with the running application?

Is this project still active?

Doing some cursory Googling, this still seems to be the best 'nice node repl' around, but the last code push was like 2016, and there are a bunch of outdated package warnings when using it:

warning nesh > [email protected]: This package is discontinued. Use lodash@^4.0.0.
warning nesh > intdoc > [email protected]: This package is discontinued. Use lodash@^4.0.0.
warning nesh > babel-core > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

I figure before I fall in love with it.. is there any chance of it actually being currently maintained? And/or, are there more active alternatives you would point me to instead?

Error in plugin history: // > Error: ENOENT: no such file or directory,

Hey,
I'm using a 3rd-party plugin of sublime text 3 ,named "worksheet".
It can do inline evaluation code such as nodejs,etc.
By given the following params,it works(running on a js file located at D:\ drive on Windows10X64):
`{
"worksheet_languages": {

    "JavaScript (Babel)": {
        "cmd": "nesh -b ",
        "prompt": ["babel> ", "\\.\\.+ "],
        "ignore": ["^\\n"]
    }        
}

}`

However, everytime I run this evaluation,it will give me a warning that
Error in plugin history: // > Error: ENOENT: no such file or directory, open 'D:\Users\mzvast\.babel_history'
If I copy the js file to C:\ drive ,then everything is fine.
So,It seem the nesh not getting the process.env.HOME right.
Then,I set a symlink from C:\Users\mzvast.babel_history to D:\Users\mzvast.babel_history,everything is fine again.

But this is hacking,Not a solution.So anyone encountered this issue?Help me figure it out,thx~

Setting/filtering output

These are feature requests that I would like to see (or know about if they already exist). If I get the time, I may work on them myself and post or PR.

Both features could be implemented by setting up a filter on all return statements.

I would like to truncate some of my error messages (ReferenceError: foo is not defined could be under 5 lines, for me, for example). I would also like to define a prompt for returned statements. It could look something like:

my_prompt> 2 + 2
=> 4

where '=>' is defined by the user.

Is there a way to set the history file without writing code?

I skimmed through the code and it doesn't look like I could change the history file without writing javascript to run nesh.start with opts: {historyFile: ...} or extending nesh and setting nesh.defaults. Am I wrong?

It would nice to be able to set the history file with command line args or environment variables. Preferably environment variables so I can export them in my .profile.

node allows setting the file through environment variables. Maybe NESH_REPL_HISTORY and NESH_HISTORY_SIZE. I've been looking around for a repl that has reverse search, tab completion, and runs in a terminal. Nesh has all of those. I've been using rlwrap on node which doesn't have tab completion.

Command line access

It would be nice if it could allow access to the command line (like ipython). That is, the user should still be able to traverse the filesystem while in nesh.

Is there a plugin for this?

Use just `process.env.USERPROFILE` to determine a user's home folder on Windows

I'm happy to provide this as a pull request, but I thought I'd first make sure I'm not missing anything:

config.js uses the following to determine a user's home directory for both Unix-like and Windows platforms:

process.env.HOME or process.env.HOMEPATH or process.env.USERPROFILE

However, %HOMEPATH% doesn't contain a drive spec. (e.g., it contains only \Users\Jdoe rather than C:\Users\Jdoe), whereas %USERPROFILE% does include the drive spec., which makes it the better choice.

AFAIK, %USERPROFILE% is defined on all Windows flavors, so I suggest simply using

process.env.HOME or process.env.USERPROFILE

Let me know if that makes sense.

Nesh language extension (wisp)

Just thought I'd drop it here (as well). I hacked together a quick wisp language extension for nesh using the included source (courtesy of) babel. Not sure if I did everything right but the minimal working example I guess. Any Clojure-aficionados like myself might appreciate it; works nicely with macro's too - better than wisps own REPL.

https://gist.github.com/robjens/65d5639859cfe4fd331d

Unable to require module inside eval file

If I try nesh.js as:

.require nconf

I get:

[tfalgout@beyondinto-lm necs]$ nesh -b --eval nesh.js
Babel 5.8.38 on Node v5.2.0
Type .help for more information
babel> Error in plugin eval:
SyntaxError: Unexpected token .
    at Object.exports.runInThisContext (vm.js:54:16)
    at exports.postStart (/usr/local/lib/node_modules/nesh/lib/plugins/eval.js:24:19)
    at callPluginMethod (/usr/local/lib/node_modules/nesh/lib/nesh.js:73:9)
    at process (/usr/local/lib/node_modules/nesh/lib/nesh.js:40:16)
    at /usr/local/lib/node_modules/nesh/lib/nesh.js:52:18
    at callPluginMethod (/usr/local/lib/node_modules/nesh/lib/nesh.js:78:14)
    at process (/usr/local/lib/node_modules/nesh/lib/nesh.js:40:16)
    at process (/usr/local/lib/node_modules/nesh/lib/nesh.js:55:16)
    at processPlugins (/usr/local/lib/node_modules/nesh/lib/nesh.js:58:12)
    at /usr/local/lib/node_modules/nesh/lib/nesh.js:105:14
undefined
babel>

If I try:

const nconf = require('nconf');

I get:

[tfalgout@beyondinto-lm necs]$ nesh -b --eval nesh.js
Babel 5.8.38 on Node v5.2.0
Type .help for more information
babel> Error in plugin eval:
Error: Cannot find module 'nconf'
    at Function.Module._resolveFilename (module.js:327:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:355:17)
    at require (internal/module.js:13:17)
    at evalmachine.<anonymous>:1:15
    at Object.exports.runInThisContext (vm.js:55:17)
    at exports.postStart (/usr/local/lib/node_modules/nesh/lib/plugins/eval.js:24:19)
    at callPluginMethod (/usr/local/lib/node_modules/nesh/lib/nesh.js:73:9)
    at process (/usr/local/lib/node_modules/nesh/lib/nesh.js:40:16)
    at /usr/local/lib/node_modules/nesh/lib/nesh.js:52:18
undefined
.exit

Is there something I'm missing?

Proof that I do have the nconf module:

[tfalgout@beyondinto-lm necs]$ nesh -b
Babel 5.8.38 on Node v5.2.0
Type .help for more information
babel> .require nconf
nconf = require("nconf")
nconf = require("./nconf")
babel> nconf

Support passing arguments to node

Similar to coffeescript's --nodejs option, it would be nice to be able to pass arguments to node when using nesh.

My use case is that I have a script that I run on start using the -e option, it loads a lot of modules for convenience, and I'd like to use --harmony-proxies to lazy load them (using a pattern similar to what python's nltk does).

Access to `optimist` used to generate help documentation correctly

I've written a plugin for nesh and it takes a command line option (-f or --fibrous). I'd like to use optimist.describe() to document what the option does so that users who run:
nesh --help
will see it listed there, but since when I require('optimist') within my plugin, I don't get the same optimist object, so when I call .describe() on it, it doesn't have any effect.

If you could expose that as nesh.optimist or something, that would make it easy to add help documentation.

If you're open to it, I can write a patch and submit a pull request when I have time.

multi line for babel ?

 nesh -b
Babel 5.8.38 on Node v6.0.0
Type .help for more information
babel> var a = [
SyntaxError: unknown: Unexpected token (2:0)
var a = [

without babel it's ok to write multi lines

nesh> var a = [
...   {a: 'a', b: 4},
...   {a: 'c', b: 5}, ]
undefined
nesh> a
[ { a: 'a', b: 4 }, { a: 'c', b: 5 } ]

Error Running nesh --plugins or --enable or --disable

Installed nesh using
npm install -g nesh
Warnings were returned, but no errors

Running nesh --plugins returns the following error:

`$ nesh --plugins
/data/data/com.termux/files/usr/lib/node_modules/nesh/lib/nesh.js:173 return callback("Could not find plugin '" + name + "': " + e + "!");
^

RangeError: Maximum call stack size exceeded
at Object.nesh.loadPlugin (/data/data/com.termux/files/usr/lib/node_modules/nesh/lib/nesh.js:173:68)
at /data/data/com.termux/files/usr/lib/node_modules/nesh/lib/plugins/autoload.js:61:21 at exports.setup (/data/data/com.termux/files/usr/lib/node_modules/nesh/lib/plugins/autoload.js:74:9) at callPluginMethod (/data/data/com.termux/files/usr/lib/node_modules/nesh/lib/nesh.js:70:14)
at Object.nesh.loadPlugin (/data/data/com.termux/files/usr/lib/node_modules/nesh/lib/nesh.js:185:14)
at /data/data/com.termux/files/usr/lib/node_modules/nesh/lib/plugins/autoload.js:61:21 at exports.setup (/data/data/com.termux/files/usr/lib/node_modules/nesh/lib/plugins/autoload.js:74:9) at callPluginMethod (/data/data/com.termux/files/usr/lib/node_modules/nesh/lib/nesh.js:70:14)
at Object.nesh.loadPlugin (/data/data/com.termux/files/usr/lib/node_modules/nesh/lib/nesh.js:185:14)
at /data/data/com.termux/files/usr/lib/node_modules/nesh/lib/plugins/autoload.js:61:21 $`

"colors" npm package does not work as expected in nesh

First things first: great project, thanks for making it freely available.

The modifications that "colors" makes to the String prototype are not effective in nesh:

require('colors'); console.log("I'm blue".blue)

The above just prints undefined. By contrast, it works fine in the node REPL, but it also does not work in the coffee REPL.

I suspect other packages that modify prototypes may be affected, too.

The curious thing is that when you inspect a string, the members added by colors DO show up in nesh.

Want to use nesh for interactive shell program

I would like to use nesh, embedded as core to an interactive shell app. Similar to node, but instead of evaluating javascript commands, the input commands would be custom commands that would invoke some operation.

for example:

./myprog

run sql 'select avg(x) from table1'
33

Could you provide skeleton prototype or point me in the right direction. Thanks.

How do I get global variables within nodejs

I have this code below. but when I start into the nesh prompt, i cannot access the global variable myvar

Is there a context to access it from? i looked at global but was not there either

Also how do I exit nesh to continue running my application event loop.

//var keypress = require('keypress');
var nesh=require("nesh");
var myvar=123;
opts = {
    welcome: 'Welcome!',
    prompt: 'test> '
};

nesh.start(opts, function (err) {
if (err) {
   nesh.log.error(err);
}
});

.load breaks on multiline files

I noticed that .load will pretty much die on any file since it just loads the file line by line. Is there something that runs like %run in ipython? I had written https://github.com/dalejung/choir awhile back, but it doesn't support babel.

Where does the .load come from? I couldn't find it in the source.

Add reverse-i-search feature

I've always been a heavy user of the reverse history search feature of bash and other REPLs. Do you think there is an easy way to add this to nesh?

Hey

Dan, been playing around with nesh, how do i add a tab while writing a coffeescript function

nesh> ap = (c) -> console.log c
... }
... }
... )
...

How do i end a function? ah just one of those things.

Thanks,
Krishna

Why method introspection does not work?

$ nesh

Node v8.11.3
Type .help for more information
nesh>
Type console
nesh> console
Hit the ctrl-q
nesh> onsol
Hit the ctrl-q again
nesh> nso
Hit the ctrl-q again again
nesh> s
Hit the ctrl-q again and again
nesh>

Combining babel and eval leads to a syntax error in eval

Eval works as expected when I attempt a simple console.log nesh -e 'console.log("hello world");'.

But if I introduce the babel flag nesh -b -e 'console.log("hello world");', the eval blows up with the following error:

Error in plugin eval:
SyntaxError: Unexpected identifier
    at Object.exports.runInThisContext (vm.js:53:16)
    at exports.postStart (/usr/local/Cellar/nvm/0.26.1/versions/node/v4.0.0/lib/node_modules/nesh/lib/plugins/eval.js:24:19)
    at callPluginMethod (/usr/local/Cellar/nvm/0.26.1/versions/node/v4.0.0/lib/node_modules/nesh/lib/nesh.js:73:9)
    at process (/usr/local/Cellar/nvm/0.26.1/versions/node/v4.0.0/lib/node_modules/nesh/lib/nesh.js:40:16)
    at /usr/local/Cellar/nvm/0.26.1/versions/node/v4.0.0/lib/node_modules/nesh/lib/nesh.js:52:18
    at callPluginMethod (/usr/local/Cellar/nvm/0.26.1/versions/node/v4.0.0/lib/node_modules/nesh/lib/nesh.js:78:14)
    at process (/usr/local/Cellar/nvm/0.26.1/versions/node/v4.0.0/lib/node_modules/nesh/lib/nesh.js:40:16)
    at process (/usr/local/Cellar/nvm/0.26.1/versions/node/v4.0.0/lib/node_modules/nesh/lib/nesh.js:55:16)
    at processPlugins (/usr/local/Cellar/nvm/0.26.1/versions/node/v4.0.0/lib/node_modules/nesh/lib/nesh.js:58:12)
    at /usr/local/Cellar/nvm/0.26.1/versions/node/v4.0.0/lib/node_modules/nesh/lib/nesh.js:105:14

Here is the version info on launch with the babel flag Babel 5.8.25 on Node v4.0.0.

And the output of nesh --version is nesh version 1.6.0. The latest version as of this post.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.