Skip to content

Commit 1ba4e59

Browse files
committed
feat(cli): support custom Vix Note assets directory
2 parents 1ae7cab + 7a91ca7 commit 1ba4e59

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

‎src/commands/NoteCommand.cpp‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ namespace
758758
int colorOverride = -1; // -1 auto, 0 off, 1 on
759759
bool noExtensions = false;
760760
bool listExtensions = false;
761+
fs::path assetsDirectory;
761762
};
762763

763764
// Returns:
@@ -855,6 +856,35 @@ namespace
855856
continue;
856857
}
857858

859+
if (arg == "--assets-dir")
860+
{
861+
if (i + 1 >= args.size())
862+
{
863+
out.error("Missing value for --assets-dir.");
864+
out.error_hint("Usage: vix note --assets-dir /path/to/share/vix/note");
865+
return 1;
866+
}
867+
868+
opts.assetsDirectory = args[++i];
869+
if (opts.assetsDirectory.empty())
870+
{
871+
out.error("Assets directory cannot be empty.");
872+
return 1;
873+
}
874+
continue;
875+
}
876+
877+
if (note_take_prefix(arg, "--assets-dir=", value))
878+
{
879+
if (value.empty())
880+
{
881+
out.error("Assets directory cannot be empty.");
882+
return 1;
883+
}
884+
opts.assetsDirectory = std::move(value);
885+
continue;
886+
}
887+
858888
if (arg == "--desktop" || arg == "--shell")
859889
{
860890
opts.desktopShell = true;
@@ -1083,10 +1113,26 @@ namespace vix::commands
10831113
return 0;
10841114
}
10851115

1116+
vix::note::NoteAssetResolveOptions assetOptions;
1117+
assetOptions.customDirectory = opts.assetsDirectory;
1118+
const auto resolvedAssets = vix::note::resolve_note_asset_directory(assetOptions);
1119+
if (!resolvedAssets.found())
1120+
{
1121+
out.error("Vix Note frontend assets were not found.");
1122+
for (const auto &path : resolvedAssets.checked)
1123+
{
1124+
out.error_hint("Checked: " + path.string());
1125+
}
1126+
out.error_hint("Reinstall Vix or set VIX_NOTE_ASSETS_DIR.");
1127+
return 1;
1128+
}
1129+
10861130
vix::note::NoteServerOptions options;
10871131
options.host = opts.host;
10881132
options.port = opts.port;
10891133
options.openBrowser = false;
1134+
options.routeOptions.assetDirectory = resolvedAssets.directory;
1135+
options.routeOptions.keepEmbeddedAssetFallback = false;
10901136
options.routeOptions.kernelOptions.projectContext = projectContext;
10911137
options.routeOptions.kernelOptions.extensionRegistry = &extensionManager.registry();
10921138
options.logRequests = (opts.logMode == NoteLogMode::Normal);

0 commit comments

Comments
 (0)