Skip to content

Commit 3cbaedc

Browse files
committed
Make replay and docs opt-in for vix run
2 parents 11e00ac + dcd6b10 commit 3cbaedc

4 files changed

Lines changed: 19 additions & 9 deletions

File tree

include/vix/cli/commands/run/RunDetail.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ namespace vix::commands::RunCommand::detail
165165

166166
bool localCache = false;
167167
bool devMode{false};
168+
bool replay = false;
168169
};
169170

170171
/**

src/commands/RunCommand.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,13 +520,12 @@ namespace
520520

521521
void apply_docs_env(const Options &opt)
522522
{
523-
if (!opt.docs.has_value())
524-
return;
523+
const bool enabled = opt.docs.has_value() && *opt.docs;
525524

526525
#ifdef _WIN32
527-
_putenv_s("VIX_DOCS", (*opt.docs ? "1" : "0"));
526+
_putenv_s("VIX_DOCS", enabled ? "1" : "0");
528527
#else
529-
::setenv("VIX_DOCS", (*opt.docs ? "1" : "0"), 1);
528+
::setenv("VIX_DOCS", enabled ? "1" : "0", 1);
530529
#endif
531530
}
532531

@@ -727,7 +726,8 @@ namespace
727726
replayConfig.replayable = true;
728727

729728
std::string replayErr;
730-
const bool replayEnabled = recorder.begin(replayConfig, replayErr);
729+
const bool replayEnabled =
730+
opt.replay && recorder.begin(replayConfig, replayErr);
731731

732732
replay::ReplayCapture replayCapture;
733733
if (replayEnabled)
@@ -1712,6 +1712,7 @@ namespace vix::commands::RunCommand
17121712
out << " -j, --jobs <n> Parallel build jobs\n";
17131713
out << " --clear <auto|always|never> Clear terminal before runtime output (default: auto)\n";
17141714
out << " --no-clear Alias for --clear=never\n\n";
1715+
out << " --replay Record this run under .vix/runs/ for vix replay\n";
17151716

17161717
out << "Runtime options (argv / env):\n";
17171718
out << " --cwd <path> Run the program with this working directory\n";
@@ -1736,9 +1737,9 @@ namespace vix::commands::RunCommand
17361737
out << " --local-cache Use local .vix-scripts instead of global cache\n";
17371738

17381739
out << "Documentation:\n";
1739-
out << " --docs Enable auto docs (sets VIX_DOCS=1)\n";
1740-
out << " --no-docs Disable auto docs (sets VIX_DOCS=0)\n";
1741-
out << " --docs=<0|1|true|false> Explicitly control docs generation\n\n";
1740+
out << " --docs Enable OpenAPI/docs for this run (sets VIX_DOCS=1)\n";
1741+
out << " --no-docs Keep OpenAPI/docs disabled (sets VIX_DOCS=0)\n";
1742+
out << " --docs=<0|1|true|false> Explicitly control OpenAPI/docs\n\n";
17421743

17431744
out << "Logging:\n";
17441745
out << " --log-level <level> trace | debug | info | warn | error | critical | off\n";
@@ -1776,6 +1777,8 @@ namespace vix::commands::RunCommand
17761777
out << " vix run main.cpp --with-mysql\n";
17771778
out << " vix run main.cpp -- -O2 -DNDEBUG --run hello 123\n";
17781779
out << " vix run main.cpp -- -lssl -lcrypto\n\n";
1780+
out << " vix run api --replay\n";
1781+
out << " vix run main.cpp --replay\n";
17791782

17801783
out << " # Runtime targets\n";
17811784
out << " vix run docker://nginx\n";

src/commands/run/RunFlow.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ namespace vix::commands::RunCommand::detail
103103
v == "--san" || v == "--ubsan" || v == "--tsan" ||
104104
v == "--docs" || v == "--no-docs" || v.rfind("--docs=", 0) == 0 ||
105105
v == "--no-color" ||
106+
v == "--replay" ||
106107
v == "--preset" || v.rfind("--preset=", 0) == 0 ||
107108
v == "--run-preset" || v.rfind("--run-preset=", 0) == 0 ||
108109
v == "--cwd" || v.rfind("--cwd=", 0) == 0 ||
@@ -445,6 +446,10 @@ namespace vix::commands::RunCommand::detail
445446
{
446447
opt.localCache = true;
447448
}
449+
else if (a == "--replay")
450+
{
451+
opt.replay = true;
452+
}
448453
else if (a == "--dev-mode")
449454
{
450455
opt.devMode = true;

src/commands/run/RunScript.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,8 @@ namespace vix::commands::RunCommand::detail
758758
replayConfig.replayable = true;
759759

760760
std::string replayErr;
761-
const bool replayEnabled = recorder.begin(replayConfig, replayErr);
761+
const bool replayEnabled =
762+
opt.replay && recorder.begin(replayConfig, replayErr);
762763

763764
replay::ReplayCapture replayCapture;
764765
if (replayEnabled)

0 commit comments

Comments
 (0)