scriptcs-sublime
scriptcs-sublime copied to clipboard
Error occurs when running a script that uses Console.Readkey / ReadLine
Found package reference: C:\code\scriptcs\samples\servicestackhost\packages\ServiceStack.3.9.37\lib\net35
Found package reference: C:\code\scriptcs\samples\servicestackhost\packages\ServiceStack.Common.3.9.37\lib\net35
Found package reference: C:\code\scriptcs\samples\servicestackhost\packages\ServiceStack.Redis.3.9.37\lib\net35
Found package reference: C:\code\scriptcs\samples\servicestackhost\packages\ServiceStack.Text.3.9.37\lib\net35
listening on http://*:999/
Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
at System.Console.ReadKey(Boolean intercept)
at Submission#0..ctor(Session session, Object& submissionResult)
at Submission#0.<Factory>(Session session)
at Roslyn.Scripting.CommonScriptEngine.Execute[T](String code, String path, DiagnosticBag diagnostics, Session session, Boolean isInteractive)
at Roslyn.Scripting.Session.Execute(String code)
at ScriptCs.Wrappers.SessionWrapper.Execute(String code) in c:\code\scriptcs\src\ScriptCs.Core\Wrappers\SessionWrapper.cs:line 17
at ScriptCs.ScriptExecutor.Execute(String script, IEnumerable`1 paths, IEnumerable`1 scriptPacks) in c:\code\scriptcs\src\ScriptCs.Core\ScriptExecutor.cs:line 47
at ScriptCs.Program.Main(String[] args) in c:\code\scriptcs\src\ScriptCs\Program.cs:line 28
[Finished in 10.6s]
Looks like a buffer needs to be passed the process.
I think there are some limitations to setting stdin to build-processes in Sublime Text. However, this plug-in - https://github.com/eric-wieser/build-with-input - enables build with input. I will try the plugin in conjunction with scriptcs some time this week and see if it is doable.
For REPL-style programming (or scripts where you need input) Sublime-REPL is commonly used.
Great, thanks Jonas!
On Sun, Mar 10, 2013 at 12:46 PM, Jonas Follesø [email protected]:
I think there are some limitations to setting stdin to build-processes in Sublime Text. However, this plug-in - https://github.com/eric-wieser/build-with-input - enables build with input. I will try the plugin in conjunction with scriptcs some time this week and see if it is doable.
For REPL-style programming (or scripts where you need input) Sublime-REPL is commonly used.
— Reply to this email directly or view it on GitHubhttps://github.com/scriptcs/scriptcs-sublime/issues/6#issuecomment-14687768 .
I tried the build-with-input pligin, and it works for Console.ReadLine() and Console.Read(), but not Console.ReadKey() - I still get the exception you reported.
I do think this is a limitation to the build system in Sublime Text. I will investigate further when I find time to see if this has been solved in other, more popular language plugins (such as Ruby).
any news on this?