Replcommands#612
Conversation
…maintain the references correctly. This not an ideal fix at this moment as it requires copying the list of references over and over, but if we move to refactor the ScriptEngine we will address it anyway - this is out of scope here.
There was a problem hiding this comment.
Maybe we should filter out abstract classes? And also, shouldn't this be combined with discovery of other types (through MEF?)?
There was a problem hiding this comment.
And if we stick with this, maybe GetExportedTypes instead of GetTypes, we want to respect types' privacy 😉
|
@filipw can you bring this up to date? |
|
Fixed some issues and updated to latest, so it's mergeable again. |
There was a problem hiding this comment.
What's the reason for this change?
There was a problem hiding this comment.
It was not properly checked all along, when not possible to parse a version from string, version is set to new empty Version, which means minor 0, major 0
There was a problem hiding this comment.
In that case should we not check packageRef.Version != new Version()?
…ommands Conflicts: src/ScriptCs.Core/Repl.cs src/ScriptCs/Command/ExecuteReplCommand.cs
|
#726 just landed. Closing this. |
Overview
This PR introduces the infrastructure for REPL commands. Fixes #224 and #237. The design is as discussed in #583.
The command is defined as follows:
And can either execute arbitrary code, or interact with the REPL (has access to
IScriptExecutor). If it returns the value, it's printed to the REPL too. It should now enable easy extensiblity i.e. do something like requested in #402 or #427The interesting thing is that you can also pass context variables to the REPL. For example:
Will pass
hellostring and1to command. This is done by evaluating the argument with theScriptEngine- if it returns a value, use it, otherwise assume it's just a string.Commands included
Converted the existing REPL commands to this approach:
CwdCommand(show working directory)CdCommand(change workign directory)ClearCommand(cls)ResetCommand(reset executor)Also added
InstallCommand- this fixes #609.You can now do:
:install myPackage:install myPackage 0.3:install myPackagae 0.3 -preExtra points
AppDomain. The idea was that as long as you have a DLL withIReplCommand, it should be discovered. This is a bit too invasive, so we may want to change it for a better approach. At the moment it's not integrated with Modules, but it should be trivial to do.:- I think it's actually better to have a uniform way rather than have a couple of commands starting with#because Roslyn does that, and have the rest start with:. But of course it would be possible to have "system" commands that start with#.Replclass. There are better ways to do it but I didn't want to do too much in one PR. See issue Make REPL injectable and overrideable like other services #434 - I think this should be tackled next.Let me know what you think!