mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-06-09 16:00:15 +00:00
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:
@@ -61,6 +61,9 @@ livesync-cli [database-path] [command] [args...]
|
||||
|
||||
- `database-path`: Path to the directory where `.livesync` folder and `settings.json` are (or will be) located.
|
||||
- Note: In previous versions, this was referred to as the "vault" path. Now it is clearly distinguished from the actual vault (the directory containing your `.md` files).
|
||||
- `--vault <path>` / `-V <path>`: (daemon/mirror only) Path to the vault directory containing `.md` files.
|
||||
- Allows the PouchDB database directory and the actual vault directory to be different locations.
|
||||
- For `mirror` command, the positional `[vault-path]` argument takes precedence over `--vault`.
|
||||
|
||||
### Commands
|
||||
|
||||
@@ -312,6 +315,7 @@ Options:
|
||||
--verbose, -v Enable verbose logging
|
||||
--debug, -d Enable debug logging (includes verbose)
|
||||
--interval <N>, -i <N> (daemon only) Poll CouchDB every N seconds instead of using the _changes feed
|
||||
--vault <path>, -V <path> (daemon/mirror) Path to vault directory, decoupled from database-path
|
||||
--help, -h Show this help message
|
||||
|
||||
Commands:
|
||||
@@ -332,7 +336,8 @@ Commands:
|
||||
info <path> Show file metadata including current and past revisions, conflicts, and chunk list
|
||||
rm <path> Mark file as deleted in local database
|
||||
resolve <path> <rev> Resolve conflict by keeping the specified revision
|
||||
mirror [vaultPath] Mirror database contents to the local file system (vaultPath defaults to database-path)
|
||||
mirror [vaultPath] Mirror database contents to the local file system
|
||||
(vaultPath positional arg > --vault flag > database-path)
|
||||
```
|
||||
|
||||
Run via npm script:
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user