Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: add support for --interactive-eval (-ie) flag #1207

Closed
wants to merge 1 commit into from

Conversation

Fishrock123
Copy link
Contributor

Fixes #1197

This achieves the desired -ie behaviour of pre-loading the eval expression into, and opening the repl.

iojs -ie "var life = 42"
undefined
> life
42
> 
iojs -ie "console.log('hello world')"
hello world
undefined
> 

I'll setup a test in test-repl-options if this looks reasonable, also, not sure if this needs to be documented in --help or not.

Edit: another thing, what subsystem: should this be?

/cc @bnoordhuis
/first time I've ever touched C++ \o/

@Fishrock123 Fishrock123 added the repl Issues and PRs related to the REPL subsystem. label Mar 19, 2015
@Fishrock123
Copy link
Contributor Author

Oh, looks like I should also add some doc in repl.markdown...

hmm, options.domain is not documented there either..

@silverwind
Copy link
Contributor

Maybe change --help to just always enter the REPL? Would also remove the only multi-line help :)

@rvagg
Copy link
Member

rvagg commented Mar 19, 2015

I'm not a fan of the multi-char short version where -ie means a specific thing and not a combination of things. -pe sucks as a special case but it's effectively -p and -e whereas you've framed -i and -e as a single thing, particularly by adding the long-hand version of it --interactive-eval.

The commandline arg parser is a bit too simplistic at the moment and this makes it less POSIX friendly, you should be able to combine arguments and have it make sense, what would -pie do? I would expect that adding p i and e together make something (and not just FOOD).

Perhaps -i needs to be about dropping into a REPL, in which case maybe -r makes more sense? -pie would make sense then as a combination of -pe and a repl. But note that we'd have to tokenizing these args properly.

Basically, I'm a soft -1 on this because I can see the headache of improving our command-line arg parsing at some point in the future when -ie is an single thing and not a strict combination of two things. Am I making sense?

@silverwind
Copy link
Contributor

I agree, hardcoding stuff like -pe and -ie isn't really great. I'd prefer that the parser is flexible enough to detect joined args, so -ep and -ei also work for example. If certain combinations of args make no sense, we should probably error out before trying to guess what the user meant.

@Fishrock123
Copy link
Contributor Author

Basically, I'm a soft -1 on this because I can see the headache of improving our command-line arg parsing at some point in the future when -ie is an single thing and not a strict combination of two things.

I agree with that. I was actually quite surprised to find these things were hardcoded.

I'd say -ie is a combination of the two, but simply enabling both under the hood doesn't (won't) work. (edit: actually, it probably could). I didn't really know how to change the long-hand arguments to match that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants