|
1 | | -# reply |
2 | | -Vix.cpp CLI reply command. |
| 1 | +# Vix Reply |
| 2 | + |
| 3 | +Interactive REPL engine for Vix. |
| 4 | + |
| 5 | +Vix Reply powers the interactive `vix` and `vix repl` experience. It provides a fast shell for expressions, variables, JSON values, runtime helpers, and real C++ snippets powered by the Vix run pipeline. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +Start the REPL: |
| 10 | + |
| 11 | +```bash |
| 12 | +vix |
| 13 | +``` |
| 14 | + |
| 15 | +Or start it explicitly: |
| 16 | + |
| 17 | +```bash |
| 18 | +vix repl |
| 19 | +``` |
| 20 | + |
| 21 | +Pass arguments to the REPL: |
| 22 | + |
| 23 | +```bash |
| 24 | +vix repl -- --port 8080 --mode dev |
| 25 | +``` |
| 26 | + |
| 27 | +Inside the REPL: |
| 28 | + |
| 29 | +```text |
| 30 | +Vix.args() |
| 31 | +``` |
| 32 | + |
| 33 | +## Example |
| 34 | + |
| 35 | +```text |
| 36 | +>>> println("Hello from Vix Reply") |
| 37 | +Hello from Vix Reply |
| 38 | +
|
| 39 | +>>> 1 + 2 * 3 |
| 40 | +7 |
| 41 | +
|
| 42 | +>>> name = "Vix" |
| 43 | +name = "Vix" |
| 44 | +
|
| 45 | +>>> type(name) |
| 46 | +string |
| 47 | +``` |
| 48 | + |
| 49 | +## C++ snippets |
| 50 | + |
| 51 | +Vix Reply can run real C++ snippets through `vix run`. |
| 52 | + |
| 53 | +```text |
| 54 | +>>> :cpp |
| 55 | +C++ mode. Type :run to execute or :cancel to exit. |
| 56 | +cpp> #include <vix/print.hpp> |
| 57 | +... int main() { |
| 58 | +... vix::print("Hello from C++"); |
| 59 | +... } |
| 60 | +Hello from C++ |
| 61 | +``` |
| 62 | + |
| 63 | +You can also start a small Vix HTTP server from the REPL: |
| 64 | + |
| 65 | +```text |
| 66 | +>>> :cpp |
| 67 | +cpp> #include <vix.hpp> |
| 68 | +... using namespace vix; |
| 69 | +... |
| 70 | +... int main() { |
| 71 | +... App app; |
| 72 | +... |
| 73 | +... app.get("/", [](Request&, Response& res) { |
| 74 | +... res.send("Hello, world"); |
| 75 | +... }); |
| 76 | +... |
| 77 | +... app.run(8080); |
| 78 | +... } |
| 79 | +``` |
| 80 | + |
| 81 | +Then test it: |
| 82 | + |
| 83 | +```bash |
| 84 | +curl http://localhost:8080 |
| 85 | +``` |
| 86 | + |
| 87 | +## Features |
| 88 | + |
| 89 | +- Interactive prompt |
| 90 | +- Persistent history |
| 91 | +- Line editing |
| 92 | +- History navigation |
| 93 | +- Basic math evaluation |
| 94 | +- Variables and JSON values |
| 95 | +- Function-style calls |
| 96 | +- Runtime helpers through `Vix` |
| 97 | +- Real C++ snippets powered by `vix run` |
| 98 | + |
| 99 | +## Built-in commands |
| 100 | + |
| 101 | +```text |
| 102 | +help |
| 103 | +version |
| 104 | +pwd |
| 105 | +cd <dir> |
| 106 | +clear |
| 107 | +history |
| 108 | +history clear |
| 109 | +exit |
| 110 | +``` |
| 111 | + |
| 112 | +## C++ mode commands |
| 113 | + |
| 114 | +```text |
| 115 | +:cpp Enter C++ snippet mode |
| 116 | +:run Run the current C++ snippet |
| 117 | +:cancel Cancel C++ snippet mode |
| 118 | +``` |
| 119 | + |
| 120 | +## Important note |
| 121 | + |
| 122 | +Vix Reply is not a full C++ interpreter. |
| 123 | + |
| 124 | +C++ snippet mode writes the snippet to a temporary `.cpp` file and runs it through `vix run`. The code is validated by the real C++ compiler and uses the normal Vix build, diagnostics, and runtime behavior. |
| 125 | + |
| 126 | +## Documentation |
| 127 | + |
| 128 | +Full documentation is available here: |
| 129 | + |
| 130 | +```text |
| 131 | +https://docs.vixcpp.com/cli/repl |
| 132 | +``` |
| 133 | + |
| 134 | +## Module layout |
| 135 | + |
| 136 | +```text |
| 137 | +include/vix/reply/ |
| 138 | + api/ |
| 139 | + console/ |
| 140 | + core/ |
| 141 | +
|
| 142 | +src/ |
| 143 | + api/ |
| 144 | + console/ |
| 145 | + core/ |
| 146 | +``` |
| 147 | + |
| 148 | +## Public entry point |
| 149 | + |
| 150 | +```cpp |
| 151 | +#include <vix/reply/core/ReplFlow.hpp> |
| 152 | + |
| 153 | +int repl_flow_run(const std::vector<std::string>& replArgs); |
| 154 | +``` |
| 155 | +
|
| 156 | +The Vix CLI uses this entry point to implement: |
| 157 | +
|
| 158 | +```bash |
| 159 | +vix repl |
| 160 | +``` |
| 161 | + |
| 162 | +## Roadmap |
| 163 | + |
| 164 | +- [x] Interactive REPL prompt |
| 165 | +- [x] Persistent history |
| 166 | +- [x] Line editing |
| 167 | +- [x] History navigation |
| 168 | +- [x] Math evaluation |
| 169 | +- [x] Variables and JSON values |
| 170 | +- [x] Runtime helpers through `Vix` |
| 171 | +- [x] C++ snippet mode powered by `vix run` |
| 172 | +- [x] C++ snippets with normal Vix diagnostics |
| 173 | +- [x] Clean Ctrl+C behavior for long-running snippets |
| 174 | +- [ ] Better autocomplete for variables and helpers |
| 175 | +- [ ] Better multiline editing |
| 176 | +- [ ] Snippet cache reuse |
| 177 | +- [ ] Better C++ snippet session management |
| 178 | +- [ ] More structured REPL diagnostics |
| 179 | +- [ ] More runtime helpers |
| 180 | + |
| 181 | +## License |
| 182 | + |
| 183 | +MIT |
0 commit comments