-
Notifications
You must be signed in to change notification settings - Fork 370
Adds new -e and --eval options which will immediately execute a script #1129
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
Conversation
4a42570 to
14abb8f
Compare
|
|
||
| namespace ScriptCs.Command | ||
| { | ||
| internal class ExecuteLooseScriptCommand : IExecuteLooseScriptCommand |
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.
this is almost a copy of ExecuteScriptCommand, the only difference appears to be _scriptExecutor.Execute vs _scriptExecutor.ExecuteScript.
It would be better to add a common abstract class and share most of the logic
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.
Ok sounds good.
|
@glennblock this is great, very welcome option. What I do in a scriptcs extension for VS Code, to allow script snippet evaluation is I saved it to a temp file (lol https://github.com/filipw/vscode-scriptcs-runner/blob/master/src/extension.ts#L81) and invoke that haha so it's very welcome Just left a comment to avoid code copying/duplication |
|
Great suggestion. Glad you find it useful. |
|
Also, according to TC this PR has 28 failing tests, so can you please double check everything passes OK |
|
Yeah it is very inconsistent that this path error pops up
|
|
It probably depends which build agent it runs on. |
|
Scratch that. The test failures are genuine. I can reproduce them locally. They were introduced with the merge of #1134 If I build the commit on the dev branch immediately before that merge, everything is fine. |
|
how is that possible, given that the build status reported on that PR was green |
|
@adamralph looking into this now |
|
@adamralph I see the errors. I'm going to fix in the original branch and send another PR. |
|
Working on this, I think I see the issue. On Sun, Feb 28, 2016 at 6:09 PM Adam Ralph notifications@github.com wrote:
|
|
Fixed. I'll send a new PR shortly. On Sun, Feb 28, 2016 at 6:54 PM Glenn Block glenn.block@gmail.com wrote:
|
|
@adamralph @filipw all tests passing now based on my last DOH fix. |
|
@adamralph any idea why TC seems to be slow in picking up the changes? |
|
@filipw ready to merge! |
@glennblock Codebetter CI is just slow 😒 |
|
@scriptcs/core this is waiting on someone to click merge ;-) |
|
@adamralph Travis is lying |
|
@glennblock I kicked off the build again and it passed. |
|
|
||
| var assemblyPaths = Enumerable.Empty<string>(); | ||
| var workingDirectory = _fileSystem.CurrentDirectory; | ||
| assemblyPaths = _assemblyResolver.GetAssemblyPaths(workingDirectory); |
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.
The declaration and assignment of assemblyPaths can be combined on this line.
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.
You are being a little anal here
| directory = ScenarioDirectory.Create(scenario); | ||
| if (Environment.OSVersion.Platform == PlatformID.Win32NT) | ||
| { | ||
| script = @"Console.WriteLine(""""""Hello World!"""""");"; |
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.
Why does Windows need 3 double quotes?
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.
Because it does. This has been thoroughly tested and it is apparently by design.
|
@glennblock I left a couple of comments regarding the implementation. Regarding behaviour, I'd like to investigate the result of combinations of a filename, an eval script and the REPL switch:
|
|
I see your point, but these seem like small issues to me. The manor use case here is to allow immediately executing a command that is passed at the command line. The other combinations are nice to have, sure they bring more consistency, but still nice to have and unlikely to be used. Using -r however is there to allow pre-loading a bunch of stuff when you come into the REPL so it executes and then you can use the loaded objects. This feels far less valuable in this context. |

This fixes #1085
Update:
-ewas chosen to align with the existing *nix precedent. Mono's REPL uses this and node as well. Thanks to @migueldeicaza for the suggestion!It adds a new switch for immediately executing loose code. Also adds a new convenience overload to the
ScriptCsExe.Run()method.example:
Note: Depending on the shell you use you may have to jump through different hoops for passing spaces / quoted strings. The example is using Powershell. To do this from the cmd prompt you would use: