fix(cli): respect mirror positional arg before --vault flag

Per vrtmrz's review feedback, restore the mirror [vault-path] positional
argument support with correct priority order:
  mirror positional arg > --vault flag > databasePath

Also update --vault help text and CLI README with the new option.
This commit is contained in:
郑泽宇
2026-06-05 11:50:23 +08:00
parent fff6df535f
commit be979a3bf1
2 changed files with 14 additions and 3 deletions
+8 -2
View File
@@ -304,11 +304,17 @@ export async function main() {
: path.join(databasePath, SETTINGS_FILE);
configureNodeLocalStorage(path.join(databasePath, ".livesync", "runtime", "local-storage.json"));
// Resolve vault path: --vault flag takes priority, otherwise fall back to databasePath
// Resolve vault path: mirror positional argument takes priority,
// then --vault flag, otherwise fall back to databasePath.
// For daemon mode, enable chokidar file watching so the _changes feed picks up events.
// mirror runs a single full scan and doesn't need continuous watching.
const watchEnabled = options.command === "daemon";
const vaultPath = options.vaultPath ? path.resolve(options.vaultPath) : databasePath!;
const vaultPath =
options.command === "mirror" && options.commandArgs[0]
? path.resolve(options.commandArgs[0])
: options.vaultPath
? path.resolve(options.vaultPath)
: databasePath!;
infoLog(`Self-hosted LiveSync CLI`);
infoLog(`Database Path: ${databasePath}`);