-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
feat(repl): add --eval flag for evaluating code when the repl starts #11590
Conversation
.long("eval") | ||
.help("Evaluates the provided code when the REPL starts.") | ||
.takes_value(true) | ||
.value_name("code"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed some parts of the code require an equals sign. Should this? deno repl --eval="console.log(5);"
? I'm not sure when to use the equals sign and when not to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it shouldn't require equals. The equals sign is required in some places to disambiguate. I don't remember the exact situation off hand, but we should attempt to remove the equals-sign-requirement if the ambiguity has evaporated.
if let EvaluationOutput::Error(error_text) = output { | ||
println!("error in --eval flag. {}", error_text); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was super easy to implement this thanks to the recent refactorings in this code 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too
a36a260
to
710983e
Compare
Closes #3173
At the moment, this only adds support for an
--eval <code>
flag to provide some code to execute on startup.For example:
deno repl --eval 'import * as hash from "https://deno.land/std@0.77.0/hash#stdhash"'
We will consider adding support for URL and file paths in the future, but for now this is a first step.