Skip to content

Commit 28e2d3f

Browse files
committed
fix(run): align cache and execution behavior
1 parent bf78485 commit 28e2d3f

5 files changed

Lines changed: 36 additions & 22 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ namespace vix::commands::RunCommand::detail
720720
/**
721721
* @brief Compute the global cache root used for directly compiled scripts.
722722
*/
723-
fs::path get_direct_scripts_cache_root();
723+
fs::path get_direct_scripts_cache_root(bool localCache = false);
724724

725725
/**
726726
* @brief Compute the cache key used for a directly compiled script.

‎include/vix/cli/commands/run/detail/DirectScriptRunner.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace vix::commands::RunCommand::detail
2626
/**
2727
* @brief Return the global cache root used for directly compiled scripts.
2828
*/
29-
fs::path get_direct_scripts_cache_root();
29+
fs::path get_direct_scripts_cache_root(bool localCache);
3030

3131
/**
3232
* @brief Compute the cache key used for a directly compiled script.

‎src/commands/RunCommand.cpp‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ namespace
15111511
for (const auto &a : args)
15121512
{
15131513
out += " ";
1514-
out += a;
1514+
out += vix::commands::RunCommand::detail::quote(a);
15151515
}
15161516
return out;
15171517
};
@@ -1537,7 +1537,7 @@ namespace
15371537
std::string cmd =
15381538
"docker run -it --rm " +
15391539
join_args(opt.runArgs) + " " +
1540-
image;
1540+
vix::commands::RunCommand::detail::quote(image);
15411541

15421542
return std::system(cmd.c_str());
15431543
}
@@ -1550,7 +1550,7 @@ namespace
15501550
std::string target = raw.substr(6);
15511551

15521552
std::string cmd =
1553-
"ssh " + target +
1553+
"ssh " + vix::commands::RunCommand::detail::quote(target) +
15541554
join_args(opt.runArgs);
15551555

15561556
return std::system(cmd.c_str());
@@ -1563,7 +1563,7 @@ namespace
15631563
raw.rfind("https://", 0) == 0)
15641564
{
15651565
std::string cmd =
1566-
"curl -L " + raw +
1566+
"curl -L " + vix::commands::RunCommand::detail::quote(raw) +
15671567
join_args(opt.runArgs);
15681568

15691569
return std::system(cmd.c_str());
@@ -1694,9 +1694,10 @@ namespace vix::commands::RunCommand
16941694
#endif
16951695
}
16961696

1697-
return run_last_built_project(
1698-
resolved.userProjectDir,
1699-
opt);
1697+
if (opt.checkOnly)
1698+
return run_project_with_presets(resolved.userProjectDir, opt, showUi);
1699+
1700+
return run_last_built_project(resolved.userProjectDir, opt);
17001701
}
17011702

17021703
default:
@@ -1760,9 +1761,10 @@ namespace vix::commands::RunCommand
17601761
print_vue_fullstack_banner();
17611762
}
17621763

1763-
return run_last_built_project(
1764-
resolved.userProjectDir,
1765-
opt);
1764+
if (opt.checkOnly)
1765+
return run_project_with_presets(resolved.userProjectDir, opt, showUi);
1766+
1767+
return run_last_built_project(resolved.userProjectDir, opt);
17661768
}
17671769

17681770
int help()
@@ -1772,7 +1774,7 @@ namespace vix::commands::RunCommand
17721774
out << "Usage:\n";
17731775
out << " vix run [target] [options] [-- compiler/linker flags] [--run <args...>]\n\n";
17741776

1775-
out << "Build and run a C++ target with Vix.\n\n";
1777+
out << "Run a C++ file, executable, or a previously built project.\n\n";
17761778

17771779
out << "Targets:\n";
17781780
out << " project Current project or project directory/name\n";
@@ -1786,11 +1788,10 @@ namespace vix::commands::RunCommand
17861788

17871789
out << "Project:\n";
17881790
out << " -d, --dir <path> Project directory\n";
1789-
out << " --preset <name> Configure/build preset, default: dev-ninja\n";
1790-
out << " --run-preset <name> Run preset name\n";
1791-
out << " -j, --jobs <n> Number of parallel build jobs\n";
1792-
out << " --clean Clean/reconfigure before running\n";
1793-
out << " --check Build/check the current project without running it\n";
1791+
out << " --preset <name> Build preset used with --check, default: dev-ninja\n";
1792+
out << " -j, --jobs <n> Parallel build jobs used with --check\n";
1793+
out << " --clean Clean/reconfigure when used with --check\n";
1794+
out << " --check Build the project without running it\n";
17941795
out << " --replay Record this run under .vix/runs/\n\n";
17951796

17961797
out << "Runtime:\n";
@@ -1804,6 +1805,7 @@ namespace vix::commands::RunCommand
18041805
out << " --reload Alias for --watch\n";
18051806
out << " --force-server Treat the program as a long-running server\n";
18061807
out << " --force-script Treat the program as a short-lived script\n\n";
1808+
out << " --dev-mode Use the build-ninja project watch layout\n\n";
18071809

18081810
out << "Run behavior:\n";
18091811
out << " --ui Enable interactive run progress UI\n";
@@ -1838,6 +1840,7 @@ namespace vix::commands::RunCommand
18381840
out << " --clear <mode> Terminal clearing: auto, always, never\n";
18391841
out << " --no-clear Alias for --clear=never\n";
18401842
out << " --log-level <level> trace, debug, info, warn, error, critical, off\n";
1843+
out << " --loglevel <level> Alias for --log-level\n";
18411844
out << " --verbose Alias for --log-level=debug\n";
18421845
out << " -q, --quiet Alias for --log-level=warn\n";
18431846
out << " --log-format <format> kv, json, json-pretty\n";

‎src/commands/run/RunFlow.cpp‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,16 @@ namespace vix::commands::RunCommand::detail
202202
opt.autoDeps = AutoDepsMode::Local;
203203
}
204204

205-
normalize_clear_mode(opt);
206-
normalize_compiler_fingerprint(opt);
205+
normalize_clear_mode(opt);
206+
normalize_compiler_fingerprint(opt);
207+
208+
if (!opt.runPreset.empty())
209+
{
210+
error("--run-preset is not supported by vix run.");
211+
hint("Build the desired preset with `vix build --preset <name>`, then run it with `vix run`.");
212+
opt.parseFailed = true;
213+
opt.parseExitCode = 2;
214+
}
207215
}
208216

209217
void handle_positional_argument(Options &opt, const std::string &arg)

‎src/commands/run/detail/DirectScriptRunner.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,8 +1209,11 @@ namespace vix::commands::RunCommand::detail
12091209

12101210
} // namespace
12111211

1212-
fs::path get_direct_scripts_cache_root()
1212+
fs::path get_direct_scripts_cache_root(bool localCache)
12131213
{
1214+
if (localCache)
1215+
return fs::current_path() / ".vix-scripts";
1216+
12141217
#ifdef _WIN32
12151218
const char *home = vix::utils::vix_getenv("USERPROFILE");
12161219
#else
@@ -1311,7 +1314,7 @@ namespace vix::commands::RunCommand::detail
13111314
plan.fingerprint = make_direct_build_fingerprint(plan.scriptPath, probe, opt);
13121315
direct_perf_trace("fingerprint", fingerprintStart);
13131316
plan.cacheKey = direct_build_fingerprint_cache_key(plan.fingerprint);
1314-
plan.cacheDir = get_direct_scripts_cache_root() / plan.cacheKey;
1317+
plan.cacheDir = get_direct_scripts_cache_root(opt.localCache) / plan.cacheKey;
13151318

13161319
plan.binaryPath = plan.cacheDir / (plan.exeName + executable_suffix());
13171320

0 commit comments

Comments
 (0)