Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ pushwork url

**`checkout <sync-id> [path]`** - Restore to previous sync _(not yet implemented)_

### Dev Mode

The `--dev <id>` flag uses `.pushwork/dev-<id>/` instead of `.pushwork/`, giving you a separate Automerge URL for development. The id lets you maintain multiple dev configurations.

```bash
pushwork --dev <id> init # Create dev config with a new URL
pushwork --dev <id> sync # Sync to the dev URL
pushwork --dev <id> watch # Watch, build, and sync to dev URL
```

## Configuration

Configuration is stored in `.pushwork/config.json`:
Expand Down
41 changes: 24 additions & 17 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ const version = require("../package.json").version;
const program = new Command()
.name("pushwork")
.description("Bidirectional directory synchronization using Automerge CRDTs")
.version(version, "-V, --version", "output the version number");
.version(version, "-V, --version", "output the version number")
.option("--dev <id>", "Use a separate .pushwork/dev-<id> directory for development");

/** Derive the config directory from the global --dev flag */
function getConfigDir(): string {
const devId = program.opts().dev;
return devId ? `.pushwork/dev-${devId}` : ".pushwork";
}

// Init command
program
Expand All @@ -43,12 +50,12 @@ program
const [syncServer, syncServerStorageId] = validateSyncServer(
opts.syncServer
);
await init(path, { syncServer, syncServerStorageId });
await init(path, { syncServer, syncServerStorageId }, getConfigDir());
});

// Track command (set root directory URL without full initialization)
const trackAction = async (url: string, path: string, opts: { force: boolean }) => {
await root(url, path, { force: opts.force });
await root(url, path, { force: opts.force }, getConfigDir());
};

program
Expand Down Expand Up @@ -102,7 +109,7 @@ program
verbose: opts.verbose,
syncServer,
syncServerStorageId,
});
}, getConfigDir());
});

// Commit command
Expand All @@ -115,7 +122,7 @@ program
"."
)
.action(async (path, _opts) => {
await commit(path);
await commit(path, {}, getConfigDir());
});

// Sync command
Expand Down Expand Up @@ -151,7 +158,7 @@ program
gentle: opts.gentle,
nuclear: opts.nuclear,
verbose: opts.verbose,
});
}, getConfigDir());
});

// Diff command
Expand All @@ -167,7 +174,7 @@ program
.action(async (path, opts) => {
await diff(path, {
nameOnly: opts.nameOnly,
});
}, getConfigDir());
});

// Status command
Expand All @@ -183,7 +190,7 @@ program
.action(async (path, opts) => {
await status(path, {
verbose: opts.verbose,
});
}, getConfigDir());
});

// Log command
Expand All @@ -203,7 +210,7 @@ program
oneline: opts.oneline,
since: opts.since,
limit: parseInt(opts.limit),
});
}, getConfigDir());
});

// Checkout command
Expand All @@ -224,7 +231,7 @@ program
.action(async (syncId, path, opts) => {
await checkout(syncId, path, {
force: opts.force,
});
}, getConfigDir());
});

// URL command
Expand All @@ -233,7 +240,7 @@ program
.summary("Show the Automerge root URL")
.argument("[path]", "Directory path (default: current directory)", ".")
.action(async (path) => {
await url(path);
await url(path, getConfigDir());
});

// Remove command
Expand All @@ -242,7 +249,7 @@ program
.summary("Remove local pushwork data")
.argument("[path]", "Directory path (default: current directory)", ".")
.action(async (path) => {
await rm(path);
await rm(path, getConfigDir());
});

// List command
Expand All @@ -254,7 +261,7 @@ program
.action(async (path, opts) => {
await ls(path, {
verbose: opts.verbose,
});
}, getConfigDir());
});

// Config command
Expand All @@ -271,7 +278,7 @@ program
await config(path, {
list: opts.list,
get: opts.get,
});
}, getConfigDir());
});

// Watch command
Expand Down Expand Up @@ -299,7 +306,7 @@ program
script: opts.script,
watchDir: opts.dir,
verbose: opts.verbose,
});
}, getConfigDir());
});

// Completion command (hidden from help)
Expand Down Expand Up @@ -361,11 +368,11 @@ program.command("completion", { hidden: true }).action(() => {
_pushwork() {
local -a commands
commands=(${commands})

_arguments -C \\
'1: :->command' \\
'*::arg:->args'

case $state in
command)
_describe 'command' commands
Expand Down
Loading