diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-02-03 22:42:36 -0500 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-02-20 09:45:29 -0500 |
commit | 1bd03ad100e8813751b6c08b0c21ae8cf5a9c21d (patch) | |
tree | 2e625eda7966d2e10bf7316ae8fa352eaa100b27 /src/libcmd/repl.hh | |
parent | 57a2e46ee0890093c9882f961d7d95c56d7c0ad5 (diff) |
Split out `CmdRepl` and `editorFor`
The REPL itself and the `nix repl` CLI are conceptually different
things, and thus deserve to be in different files.
Diffstat (limited to 'src/libcmd/repl.hh')
-rw-r--r-- | src/libcmd/repl.hh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/libcmd/repl.hh b/src/libcmd/repl.hh new file mode 100644 index 000000000..dfccc93e7 --- /dev/null +++ b/src/libcmd/repl.hh @@ -0,0 +1,39 @@ +#pragma once + +#include "eval.hh" + +#if HAVE_BOEHMGC +#define GC_INCLUDE_NEW +#include <gc/gc_cpp.h> +#endif + +namespace nix { + +struct AbstractNixRepl +{ + ref<EvalState> state; + Bindings * autoArgs; + + AbstractNixRepl(ref<EvalState> state) + : state(state) + { } + + virtual ~AbstractNixRepl() + { } + + typedef std::vector<std::pair<Value*,std::string>> AnnotatedValues; + + static std::unique_ptr<AbstractNixRepl> create( + const Strings & searchPath, nix::ref<Store> store, ref<EvalState> state, + std::function<AnnotatedValues()> getValues); + + static void runSimple( + ref<EvalState> evalState, + const ValMap & extraEnv); + + virtual void initEnv() = 0; + + virtual void mainLoop() = 0; +}; + +} |