File tree Expand file tree Collapse file tree
include/vix/cli/commands/repl Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616namespace vix ::commands::ReplCommand
1717{
18- int repl_flow_run ();
18+ int repl_flow_run (const std::vector<std::string> &replArgs );
1919}
2020
2121#endif
Original file line number Diff line number Diff line change @@ -20,20 +20,28 @@ namespace vix::commands::ReplCommand
2020{
2121 int run (const std::vector<std::string> &args)
2222 {
23- (void )args;
24- return repl_flow_run ();
23+ std::vector<std::string> replArgs = args;
24+ if (!replArgs.empty () && replArgs[0 ] == " --" )
25+ replArgs.erase (replArgs.begin ());
26+
27+ return repl_flow_run (replArgs);
2528 }
2629
2730 int help ()
2831 {
2932 std::cout
3033 << " Usage:\n "
31- << " vix repl\n\n "
34+ << " vix repl [-- <args...>] \n\n "
3235 << " Description:\n "
33- << " Start an interactive Vix REPL (CLI shell + calculator).\n\n "
36+ << " Start an interactive Vix REPL (shell + calculator).\n "
37+ << " Args after `--` are available via Vix.args().\n\n "
3438 << " Examples:\n "
3539 << " vix repl\n "
36- << " vix repl # then: = 1+2*3\n " ;
40+ << " vix repl -- --port 8080 --mode dev\n "
41+ << " # inside REPL:\n "
42+ << " # Vix.args()\n "
43+ << " # x = 1+2*3\n " ;
3744 return 0 ;
3845 }
46+
3947}
Original file line number Diff line number Diff line change @@ -446,10 +446,19 @@ namespace
446446
447447 if (m == " args" )
448448 {
449- // print JSON array
449+ // args() takes no parameters in REPL (getter only)
450+ if (!call.args .empty ())
451+ {
452+ vix::cli::repl::api::println (
453+ " error: Vix.args() takes no arguments.\n "
454+ " hint: use Vix.args() to read CLI args." );
455+ return true ;
456+ }
457+
450458 nlohmann::json j = nlohmann::json::array ();
451459 for (const auto &a : VixObj.args ())
452460 j.push_back (a);
461+
453462 vix::cli::repl::api::println (j.dump ());
454463 return true ;
455464 }
@@ -639,7 +648,7 @@ namespace
639648
640649namespace vix ::commands::ReplCommand
641650{
642- int repl_flow_run ()
651+ int repl_flow_run (const std::vector<std::string> &replArgs )
643652 {
644653 using vix::cli::repl::History;
645654 using vix::cli::repl::ReplConfig;
@@ -654,7 +663,7 @@ namespace vix::commands::ReplCommand
654663 vix::cli::repl::api::Vix VixObj (&history);
655664 std::unordered_map<std::string, nlohmann::json> vars;
656665
657- VixObj.set_args ({} );
666+ VixObj.set_args (replArgs );
658667
659668 if (cfg.enableFileHistory )
660669 {
You can’t perform that action at this time.
0 commit comments