@postonus/cli 0.1.32 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +380 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12199,7 +12199,7 @@ var schemaConverters = [new ZodToJsonSchemaConverter()];
|
|
|
12199
12199
|
var generator = new OpenAPIGenerator({ schemaConverters });
|
|
12200
12200
|
|
|
12201
12201
|
// src/config.ts
|
|
12202
|
-
import { chmod, mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
12202
|
+
import { chmod, mkdir, readFile, rm, stat, writeFile } from "fs/promises";
|
|
12203
12203
|
import { homedir } from "os";
|
|
12204
12204
|
import { dirname, join } from "path";
|
|
12205
12205
|
var DEFAULT_API_URL = "https://app.postonus.com";
|
|
@@ -12250,12 +12250,68 @@ async function clearConfig() {
|
|
|
12250
12250
|
function resolveApiUrl(config2) {
|
|
12251
12251
|
return (process.env[CLI_API_URL_ENV] || config2.apiUrl || DEFAULT_API_URL).replace(/\/$/, "");
|
|
12252
12252
|
}
|
|
12253
|
-
function resolveApiKey() {
|
|
12254
|
-
return process.env[CLI_API_KEY_ENV] || void 0;
|
|
12253
|
+
function resolveApiKey(cliToken) {
|
|
12254
|
+
return cliToken || process.env[CLI_API_KEY_ENV] || process.env.POSTONUS_TOKEN || void 0;
|
|
12255
|
+
}
|
|
12256
|
+
async function findProjectConfigDir(startDir = process.cwd()) {
|
|
12257
|
+
let current = startDir;
|
|
12258
|
+
while (true) {
|
|
12259
|
+
const candidate = join(current, ".postonus", "config.json");
|
|
12260
|
+
try {
|
|
12261
|
+
const stats = await stat(candidate);
|
|
12262
|
+
if (stats.isFile()) return join(current, ".postonus");
|
|
12263
|
+
} catch {
|
|
12264
|
+
}
|
|
12265
|
+
const parent = dirname(current);
|
|
12266
|
+
if (parent === current) break;
|
|
12267
|
+
current = parent;
|
|
12268
|
+
}
|
|
12269
|
+
return null;
|
|
12270
|
+
}
|
|
12271
|
+
async function readProjectConfig(startDir = process.cwd()) {
|
|
12272
|
+
const dir = await findProjectConfigDir(startDir);
|
|
12273
|
+
if (!dir) return null;
|
|
12274
|
+
try {
|
|
12275
|
+
const raw = await readFile(join(dir, "config.json"), "utf8");
|
|
12276
|
+
const parsed = JSON.parse(raw);
|
|
12277
|
+
if (isRecord(parsed) && isString(parsed.workspaceId)) {
|
|
12278
|
+
return {
|
|
12279
|
+
workspaceId: parsed.workspaceId,
|
|
12280
|
+
workspaceName: isString(parsed.workspaceName) ? parsed.workspaceName : void 0,
|
|
12281
|
+
defaultPlatforms: Array.isArray(parsed.defaultPlatforms) ? parsed.defaultPlatforms.filter(isString) : void 0
|
|
12282
|
+
};
|
|
12283
|
+
}
|
|
12284
|
+
} catch {
|
|
12285
|
+
return null;
|
|
12286
|
+
}
|
|
12287
|
+
return null;
|
|
12288
|
+
}
|
|
12289
|
+
async function writeProjectConfig(config2, inDir = process.cwd()) {
|
|
12290
|
+
const dir = join(inDir, ".postonus");
|
|
12291
|
+
const path = join(dir, "config.json");
|
|
12292
|
+
await mkdir(dir, { recursive: true, mode: 493 });
|
|
12293
|
+
await writeFile(path, `${JSON.stringify(config2, null, 2)}
|
|
12294
|
+
`, { mode: 420 });
|
|
12295
|
+
return path;
|
|
12296
|
+
}
|
|
12297
|
+
async function clearProjectConfig(inDir = process.cwd()) {
|
|
12298
|
+
const dir = join(inDir, ".postonus");
|
|
12299
|
+
try {
|
|
12300
|
+
await rm(join(dir, "config.json"), { force: true });
|
|
12301
|
+
return true;
|
|
12302
|
+
} catch {
|
|
12303
|
+
return false;
|
|
12304
|
+
}
|
|
12305
|
+
}
|
|
12306
|
+
async function resolveWorkspaceId(cliWorkspace) {
|
|
12307
|
+
if (cliWorkspace) return cliWorkspace;
|
|
12308
|
+
if (process.env.POSTONUS_WORKSPACE) return process.env.POSTONUS_WORKSPACE;
|
|
12309
|
+
const project = await readProjectConfig();
|
|
12310
|
+
return project?.workspaceId;
|
|
12255
12311
|
}
|
|
12256
12312
|
|
|
12257
12313
|
// src/output.ts
|
|
12258
|
-
var EXIT = { ok: 0, failure: 1, usage: 2, auth: 3, plan: 4, rateLimited: 5 };
|
|
12314
|
+
var EXIT = { ok: 0, failure: 1, usage: 2, auth: 3, plan: 4, rateLimited: 5, canceled: 130 };
|
|
12259
12315
|
var globals = {};
|
|
12260
12316
|
function setGlobalOptions(options) {
|
|
12261
12317
|
globals = options;
|
|
@@ -12264,7 +12320,21 @@ function isJsonMode() {
|
|
|
12264
12320
|
return globals.json === true;
|
|
12265
12321
|
}
|
|
12266
12322
|
function isInteractive() {
|
|
12267
|
-
if (globals.json || globals.input === false) return false;
|
|
12323
|
+
if (globals.json || globals.input === false || globals.nonInteractive === true) return false;
|
|
12324
|
+
if (process.env.CI || process.env.CLAUDE_CODE || process.env.CURSOR_AGENT || process.env.CODEX_ENV) return false;
|
|
12325
|
+
return process.stdout.isTTY && process.stdin.isTTY;
|
|
12326
|
+
}
|
|
12327
|
+
function hasConsent() {
|
|
12328
|
+
return globals.yes === true;
|
|
12329
|
+
}
|
|
12330
|
+
function isDebug() {
|
|
12331
|
+
return globals.debug === true;
|
|
12332
|
+
}
|
|
12333
|
+
function tokenOption() {
|
|
12334
|
+
return globals.token;
|
|
12335
|
+
}
|
|
12336
|
+
function shouldUseColor() {
|
|
12337
|
+
if (globals.color === false || process.env.NO_COLOR) return false;
|
|
12268
12338
|
return process.stdout.isTTY;
|
|
12269
12339
|
}
|
|
12270
12340
|
function printJson(data) {
|
|
@@ -12280,6 +12350,26 @@ function printStatus(line) {
|
|
|
12280
12350
|
process.stderr.write(`${line}
|
|
12281
12351
|
`);
|
|
12282
12352
|
}
|
|
12353
|
+
var GLYPH = {
|
|
12354
|
+
success: "\u2713",
|
|
12355
|
+
warning: "!",
|
|
12356
|
+
error: "\u2717",
|
|
12357
|
+
prompt: "?"
|
|
12358
|
+
};
|
|
12359
|
+
function printSuccess(headline) {
|
|
12360
|
+
if (globals.quiet || globals.json) return;
|
|
12361
|
+
const symbol = shouldUseColor() ? `\x1B[32m${GLYPH.success}\x1B[0m` : GLYPH.success;
|
|
12362
|
+
process.stderr.write(`${symbol} ${headline}
|
|
12363
|
+
`);
|
|
12364
|
+
}
|
|
12365
|
+
function printDebug(message) {
|
|
12366
|
+
if (!globals.debug) return;
|
|
12367
|
+
process.stderr.write(`[debug] ${message}
|
|
12368
|
+
`);
|
|
12369
|
+
}
|
|
12370
|
+
function formatRow(label, value2) {
|
|
12371
|
+
return ` ${label.padEnd(14)} ${value2}`;
|
|
12372
|
+
}
|
|
12283
12373
|
function workspaceOption() {
|
|
12284
12374
|
return globals.workspace;
|
|
12285
12375
|
}
|
|
@@ -12288,7 +12378,7 @@ function exitCodeFor(error2, status) {
|
|
|
12288
12378
|
if (error2.code === "RATE_LIMITED" || status === 429) return EXIT.rateLimited;
|
|
12289
12379
|
if (PLAN_CODES.has(error2.code) || status === 402) return EXIT.plan;
|
|
12290
12380
|
if (error2.code === "UNAUTHORIZED" || status === 401) return EXIT.auth;
|
|
12291
|
-
if (status === 400) return EXIT.usage;
|
|
12381
|
+
if (status === 400 || error2.code === "BAD_REQUEST") return EXIT.usage;
|
|
12292
12382
|
return EXIT.failure;
|
|
12293
12383
|
}
|
|
12294
12384
|
function failWith(error2, exitCode) {
|
|
@@ -12296,11 +12386,29 @@ function failWith(error2, exitCode) {
|
|
|
12296
12386
|
process.stdout.write(`${JSON.stringify(error2, null, 2)}
|
|
12297
12387
|
`);
|
|
12298
12388
|
} else {
|
|
12299
|
-
|
|
12389
|
+
const symbol = shouldUseColor() ? `\x1B[31m${GLYPH.error}\x1B[0m` : GLYPH.error;
|
|
12390
|
+
process.stderr.write(`${symbol} ${error2.message}
|
|
12391
|
+
`);
|
|
12392
|
+
if (error2.data.violations.length > 0) {
|
|
12393
|
+
for (const violation of error2.data.violations) {
|
|
12394
|
+
process.stderr.write(` - ${violation.message}
|
|
12300
12395
|
`);
|
|
12301
|
-
|
|
12302
|
-
|
|
12396
|
+
}
|
|
12397
|
+
}
|
|
12398
|
+
if (error2.context) {
|
|
12399
|
+
for (const [key, val] of Object.entries(error2.context)) {
|
|
12400
|
+
process.stderr.write(`${formatRow(key, val)}
|
|
12303
12401
|
`);
|
|
12402
|
+
}
|
|
12403
|
+
}
|
|
12404
|
+
if (error2.next && error2.next.length > 0) {
|
|
12405
|
+
process.stderr.write("\n Next steps:\n");
|
|
12406
|
+
for (const action of error2.next) {
|
|
12407
|
+
if (action.when) process.stderr.write(` ${action.when}:
|
|
12408
|
+
`);
|
|
12409
|
+
process.stderr.write(` ${action.command}
|
|
12410
|
+
`);
|
|
12411
|
+
}
|
|
12304
12412
|
}
|
|
12305
12413
|
}
|
|
12306
12414
|
process.exit(exitCode);
|
|
@@ -12311,8 +12419,8 @@ function fail(message, exitCode = EXIT.failure) {
|
|
|
12311
12419
|
exitCode
|
|
12312
12420
|
);
|
|
12313
12421
|
}
|
|
12314
|
-
function failUsage(message) {
|
|
12315
|
-
return failWith({ code: "BAD_REQUEST", message, data: { violations: [{ message }] } }, EXIT.usage);
|
|
12422
|
+
function failUsage(message, next) {
|
|
12423
|
+
return failWith({ code: "BAD_REQUEST", message, next, data: { violations: [{ message }] } }, EXIT.usage);
|
|
12316
12424
|
}
|
|
12317
12425
|
var INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/i;
|
|
12318
12426
|
function parseInstant(value2, flag) {
|
|
@@ -12325,9 +12433,14 @@ function parseInstant(value2, flag) {
|
|
|
12325
12433
|
}
|
|
12326
12434
|
function requireInteractive(what) {
|
|
12327
12435
|
if (isInteractive()) return;
|
|
12328
|
-
fail(
|
|
12436
|
+
fail(
|
|
12437
|
+
`${what} needs an interactive terminal. Pass the required flags instead, or run without --json / --non-interactive.`
|
|
12438
|
+
);
|
|
12329
12439
|
}
|
|
12330
|
-
function formatTable(headers, rows) {
|
|
12440
|
+
function formatTable(headers, rows, isTty = process.stdout.isTTY) {
|
|
12441
|
+
if (!isTty) {
|
|
12442
|
+
return [headers.join(" "), ...rows.map((row) => row.join(" "))].join("\n");
|
|
12443
|
+
}
|
|
12331
12444
|
const widths = headers.map(
|
|
12332
12445
|
(header, index) => Math.max(header.length, ...rows.map((row) => (row[index] ?? "").length))
|
|
12333
12446
|
);
|
|
@@ -12336,7 +12449,7 @@ function formatTable(headers, rows) {
|
|
|
12336
12449
|
}
|
|
12337
12450
|
|
|
12338
12451
|
// src/version.ts
|
|
12339
|
-
var CLI_VERSION = "0.1.
|
|
12452
|
+
var CLI_VERSION = "0.1.33";
|
|
12340
12453
|
|
|
12341
12454
|
// src/client.ts
|
|
12342
12455
|
var DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
@@ -12400,8 +12513,21 @@ function persistRefreshedTokens(apiUrl, oauth) {
|
|
|
12400
12513
|
});
|
|
12401
12514
|
};
|
|
12402
12515
|
}
|
|
12403
|
-
function buildClient(apiUrl, auth) {
|
|
12516
|
+
function buildClient(apiUrl, auth, workspaceId) {
|
|
12404
12517
|
const oauth = auth.kind === "oauth" ? { accessToken: auth.accessToken, refreshToken: auth.refreshToken, clientId: auth.clientId } : null;
|
|
12518
|
+
const baseFetch = oauth ? createOAuthFetch(apiUrl, oauth, persistRefreshedTokens(apiUrl, oauth)) : (request, init) => fetch(request, init);
|
|
12519
|
+
const instrumentedFetch = async (request, init) => {
|
|
12520
|
+
if (!isDebug()) {
|
|
12521
|
+
return baseFetch(request, init);
|
|
12522
|
+
}
|
|
12523
|
+
const start = Date.now();
|
|
12524
|
+
printDebug(`-> ${request.method} ${request.url}`);
|
|
12525
|
+
const response = await baseFetch(request, init);
|
|
12526
|
+
const duration3 = Date.now() - start;
|
|
12527
|
+
const reqId = response.headers.get("x-request-id");
|
|
12528
|
+
printDebug(`<- ${response.status} ${response.statusText} (${duration3}ms)${reqId ? ` [request-id:${reqId}]` : ""}`);
|
|
12529
|
+
return response;
|
|
12530
|
+
};
|
|
12405
12531
|
const link = new OpenAPILink(contract, {
|
|
12406
12532
|
url: `${apiUrl}/api/v1`,
|
|
12407
12533
|
headers: () => {
|
|
@@ -12410,21 +12536,22 @@ function buildClient(apiUrl, auth) {
|
|
|
12410
12536
|
"x-postonus-client": "cli",
|
|
12411
12537
|
...auth.kind === "api-key" ? { "x-api-key": auth.apiKey } : { authorization: `Bearer ${oauth?.accessToken}` }
|
|
12412
12538
|
});
|
|
12413
|
-
const workspace = workspaceOption();
|
|
12539
|
+
const workspace = workspaceId || workspaceOption();
|
|
12414
12540
|
if (workspace) headers.set("x-workspace-id", workspace);
|
|
12415
12541
|
return Object.fromEntries(headers);
|
|
12416
12542
|
},
|
|
12417
|
-
fetch:
|
|
12543
|
+
fetch: instrumentedFetch
|
|
12418
12544
|
});
|
|
12419
12545
|
return createORPCClient(link);
|
|
12420
12546
|
}
|
|
12421
12547
|
async function getApi() {
|
|
12422
12548
|
const config2 = await readConfig();
|
|
12423
12549
|
const apiUrl = resolveApiUrl(config2);
|
|
12424
|
-
const apiKey = resolveApiKey();
|
|
12550
|
+
const apiKey = resolveApiKey(tokenOption());
|
|
12551
|
+
const workspaceId = await resolveWorkspaceId(workspaceOption());
|
|
12425
12552
|
if (apiKey) {
|
|
12426
12553
|
const auth2 = { kind: "api-key", apiKey };
|
|
12427
|
-
return { api: buildClient(apiUrl, auth2), apiUrl, auth: auth2, config: config2 };
|
|
12554
|
+
return { api: buildClient(apiUrl, auth2, workspaceId), apiUrl, auth: auth2, config: config2, workspaceId };
|
|
12428
12555
|
}
|
|
12429
12556
|
if (!config2.accessToken || !config2.refreshToken || !config2.clientId) {
|
|
12430
12557
|
fail(`Not signed in. Run \`postonus login\`, or set ${CLI_API_KEY_ENV} for non-interactive use.`);
|
|
@@ -12444,7 +12571,7 @@ async function getApi() {
|
|
|
12444
12571
|
}
|
|
12445
12572
|
}
|
|
12446
12573
|
const auth = { kind: "oauth", accessToken, refreshToken, clientId };
|
|
12447
|
-
return { api: buildClient(apiUrl, auth), apiUrl, auth, config: config2 };
|
|
12574
|
+
return { api: buildClient(apiUrl, auth, workspaceId), apiUrl, auth, config: config2, workspaceId };
|
|
12448
12575
|
}
|
|
12449
12576
|
function describeError(cause) {
|
|
12450
12577
|
if (cause instanceof ORPCError3) {
|
|
@@ -12467,9 +12594,25 @@ function describeError(cause) {
|
|
|
12467
12594
|
function failApi(cause) {
|
|
12468
12595
|
if (cause instanceof ORPCError3) {
|
|
12469
12596
|
const data = cause.data;
|
|
12597
|
+
const nextActions = [];
|
|
12598
|
+
if (cause.code === "UNAUTHORIZED") {
|
|
12599
|
+
nextActions.push({
|
|
12600
|
+
command: "postonus login",
|
|
12601
|
+
argv: ["postonus", "login"],
|
|
12602
|
+
when: "Re-authenticate your terminal session"
|
|
12603
|
+
});
|
|
12604
|
+
} else if (cause.code === "CONTENT_TOO_LONG") {
|
|
12605
|
+
nextActions.push({
|
|
12606
|
+
command: "postonus post --thread-file <path>",
|
|
12607
|
+
when: "Split long text into a thread"
|
|
12608
|
+
});
|
|
12609
|
+
}
|
|
12470
12610
|
const error2 = {
|
|
12471
12611
|
code: cause.code,
|
|
12472
12612
|
message: describeError(cause),
|
|
12613
|
+
status: cause.code === "BAD_REQUEST" || cause.code === "UNAUTHORIZED" ? "action_required" : "error",
|
|
12614
|
+
reason: cause.code.toLowerCase(),
|
|
12615
|
+
next: nextActions.length > 0 ? nextActions : void 0,
|
|
12473
12616
|
data: { violations: data?.violations ?? [] }
|
|
12474
12617
|
};
|
|
12475
12618
|
return failWith(error2, exitCodeFor(error2, cause.status));
|
|
@@ -12559,6 +12702,17 @@ async function renderOnce(node2) {
|
|
|
12559
12702
|
await instance.waitUntilRenderFlush();
|
|
12560
12703
|
instance.unmount();
|
|
12561
12704
|
}
|
|
12705
|
+
async function confirmPrompt(message) {
|
|
12706
|
+
const readline = await import("readline/promises");
|
|
12707
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
12708
|
+
try {
|
|
12709
|
+
const answer = await rl.question(`? ${message} (y/N) `);
|
|
12710
|
+
const normalized = answer.trim().toLowerCase();
|
|
12711
|
+
return normalized === "y" || normalized === "yes";
|
|
12712
|
+
} finally {
|
|
12713
|
+
rl.close();
|
|
12714
|
+
}
|
|
12715
|
+
}
|
|
12562
12716
|
|
|
12563
12717
|
// src/commands/auth.tsx
|
|
12564
12718
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -12810,7 +12964,7 @@ async function listChannels() {
|
|
|
12810
12964
|
return;
|
|
12811
12965
|
}
|
|
12812
12966
|
if (channels2.length === 0) {
|
|
12813
|
-
printStatus("No channels connected
|
|
12967
|
+
printStatus("No channels connected in this workspace.\n\nConnect a channel:\n postonus channels connect");
|
|
12814
12968
|
return;
|
|
12815
12969
|
}
|
|
12816
12970
|
const rows = channels2.map(toRow);
|
|
@@ -12914,7 +13068,103 @@ async function connectChannel(options) {
|
|
|
12914
13068
|
if (!added) {
|
|
12915
13069
|
fail("Timed out waiting for the channel to appear. Check `postonus channels list`.");
|
|
12916
13070
|
}
|
|
12917
|
-
|
|
13071
|
+
printSuccess(`Connected ${added.platform} \u2014 ${added.name} (${added.id})`);
|
|
13072
|
+
printStatus(
|
|
13073
|
+
`
|
|
13074
|
+
Next: schedule a post to this channel:
|
|
13075
|
+
postonus post "First post" --to ${added.platform.toLowerCase()}`
|
|
13076
|
+
);
|
|
13077
|
+
}
|
|
13078
|
+
|
|
13079
|
+
// src/commands/link.ts
|
|
13080
|
+
import { render as render4 } from "ink";
|
|
13081
|
+
import * as React3 from "react";
|
|
13082
|
+
async function linkWorkspace(options) {
|
|
13083
|
+
const { api } = await getApi();
|
|
13084
|
+
let workspaces = [];
|
|
13085
|
+
try {
|
|
13086
|
+
workspaces = await api.workspace.list();
|
|
13087
|
+
} catch (error2) {
|
|
13088
|
+
return fail(`Could not list workspaces: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
13089
|
+
}
|
|
13090
|
+
if (workspaces.length === 0) {
|
|
13091
|
+
return fail("No workspaces available for your account.");
|
|
13092
|
+
}
|
|
13093
|
+
let selectedId = options.workspace || workspaceOption();
|
|
13094
|
+
if (selectedId) {
|
|
13095
|
+
const match = workspaces.find((w) => w.id === selectedId || w.name.toLowerCase() === selectedId?.toLowerCase());
|
|
13096
|
+
if (!match) {
|
|
13097
|
+
failUsage(`Workspace "${selectedId}" not found. Available: ${workspaces.map((w) => w.id).join(", ")}`);
|
|
13098
|
+
}
|
|
13099
|
+
selectedId = match.id;
|
|
13100
|
+
} else {
|
|
13101
|
+
if (!isInteractive()) {
|
|
13102
|
+
failUsage("Missing workspace. Pass -w, --workspace <id> in non-interactive mode.");
|
|
13103
|
+
}
|
|
13104
|
+
if (workspaces.length === 1 && workspaces[0]) {
|
|
13105
|
+
selectedId = workspaces[0].id;
|
|
13106
|
+
} else {
|
|
13107
|
+
selectedId = await new Promise((resolve) => {
|
|
13108
|
+
const items = workspaces.map((w) => ({
|
|
13109
|
+
value: w.id,
|
|
13110
|
+
label: w.name,
|
|
13111
|
+
hint: w.role
|
|
13112
|
+
}));
|
|
13113
|
+
const instance = render4(
|
|
13114
|
+
React3.createElement(Select, {
|
|
13115
|
+
label: "Which workspace would you like to link to this directory?",
|
|
13116
|
+
items,
|
|
13117
|
+
onSelect: (val) => {
|
|
13118
|
+
instance.unmount();
|
|
13119
|
+
resolve(val ?? void 0);
|
|
13120
|
+
}
|
|
13121
|
+
})
|
|
13122
|
+
);
|
|
13123
|
+
});
|
|
13124
|
+
}
|
|
13125
|
+
}
|
|
13126
|
+
if (!selectedId) {
|
|
13127
|
+
printStatus("Canceled.");
|
|
13128
|
+
return;
|
|
13129
|
+
}
|
|
13130
|
+
const workspace = workspaces.find((w) => w.id === selectedId);
|
|
13131
|
+
if (!workspace) {
|
|
13132
|
+
return fail(`Workspace ${selectedId} is not available.`);
|
|
13133
|
+
}
|
|
13134
|
+
const path = await writeProjectConfig({
|
|
13135
|
+
workspaceId: workspace.id,
|
|
13136
|
+
workspaceName: workspace.name
|
|
13137
|
+
});
|
|
13138
|
+
if (isJsonMode()) {
|
|
13139
|
+
printJson({
|
|
13140
|
+
status: "linked",
|
|
13141
|
+
workspaceId: workspace.id,
|
|
13142
|
+
workspaceName: workspace.name,
|
|
13143
|
+
configPath: path
|
|
13144
|
+
});
|
|
13145
|
+
return;
|
|
13146
|
+
}
|
|
13147
|
+
printSuccess(`Linked directory to ${workspace.name} (${workspace.id})`);
|
|
13148
|
+
printStatus(
|
|
13149
|
+
"Configuration saved to .postonus/config.json\n\nNext: schedule posts or inspect queue:\n postonus queue list"
|
|
13150
|
+
);
|
|
13151
|
+
}
|
|
13152
|
+
async function unlinkWorkspace() {
|
|
13153
|
+
const current = await readProjectConfig();
|
|
13154
|
+
if (!current) {
|
|
13155
|
+
if (isJsonMode()) {
|
|
13156
|
+
printJson({ status: "not_linked" });
|
|
13157
|
+
return;
|
|
13158
|
+
}
|
|
13159
|
+
printStatus("This directory is not linked to any Postonus workspace.");
|
|
13160
|
+
return;
|
|
13161
|
+
}
|
|
13162
|
+
await clearProjectConfig();
|
|
13163
|
+
if (isJsonMode()) {
|
|
13164
|
+
printJson({ status: "unlinked", workspaceId: current.workspaceId });
|
|
13165
|
+
return;
|
|
13166
|
+
}
|
|
13167
|
+
printSuccess(`Unlinked directory from ${current.workspaceName || current.workspaceId}`);
|
|
12918
13168
|
}
|
|
12919
13169
|
|
|
12920
13170
|
// src/commands/mcp.ts
|
|
@@ -12953,7 +13203,7 @@ function parseIncoming(message) {
|
|
|
12953
13203
|
var write = (message) => process.stdout.write(`${message}
|
|
12954
13204
|
`);
|
|
12955
13205
|
async function mcpServe() {
|
|
12956
|
-
const { apiUrl, auth } = await getApi();
|
|
13206
|
+
const { apiUrl, auth, workspaceId } = await getApi();
|
|
12957
13207
|
const endpoint = `${apiUrl}/api/mcp`;
|
|
12958
13208
|
if (auth.kind === "oauth" && !tokenAudiences(auth.accessToken).includes(endpoint)) {
|
|
12959
13209
|
fail("This sign-in does not cover the MCP endpoint. Run `postonus login` again to grant it.");
|
|
@@ -12970,6 +13220,9 @@ async function mcpServe() {
|
|
|
12970
13220
|
accept: "application/json, text/event-stream",
|
|
12971
13221
|
[CLI_VERSION_HEADER]: CLI_VERSION
|
|
12972
13222
|
});
|
|
13223
|
+
if (workspaceId) {
|
|
13224
|
+
headers.set("x-workspace-id", workspaceId);
|
|
13225
|
+
}
|
|
12973
13226
|
if (currentAuth.kind === "api-key") {
|
|
12974
13227
|
headers.set("x-api-key", currentAuth.apiKey);
|
|
12975
13228
|
} else if (oauth?.accessToken) {
|
|
@@ -13024,7 +13277,7 @@ async function mcpServe() {
|
|
|
13024
13277
|
|
|
13025
13278
|
// src/commands/media.ts
|
|
13026
13279
|
import { createHash } from "crypto";
|
|
13027
|
-
import { open as openFile, stat } from "fs/promises";
|
|
13280
|
+
import { open as openFile, stat as stat2 } from "fs/promises";
|
|
13028
13281
|
import { basename, extname } from "path";
|
|
13029
13282
|
var SCENARIO = "post_attachments";
|
|
13030
13283
|
function contentTypeFor(path) {
|
|
@@ -13060,7 +13313,7 @@ async function putBytes(url2, body, headers) {
|
|
|
13060
13313
|
}
|
|
13061
13314
|
async function uploadMedia(api, path) {
|
|
13062
13315
|
const contentType = contentTypeFor(path);
|
|
13063
|
-
const info = await
|
|
13316
|
+
const info = await stat2(path).catch(() => {
|
|
13064
13317
|
fail(`No such file: ${path}`);
|
|
13065
13318
|
});
|
|
13066
13319
|
if (!info.isFile()) fail(`Not a file: ${path}`);
|
|
@@ -13200,12 +13453,15 @@ async function openEditor(initial) {
|
|
|
13200
13453
|
await rm2(directory, { recursive: true, force: true });
|
|
13201
13454
|
}
|
|
13202
13455
|
}
|
|
13203
|
-
function readTargets(options) {
|
|
13456
|
+
function readTargets(options, defaultPlatforms) {
|
|
13457
|
+
const rawChannels = options.channel ?? [];
|
|
13458
|
+
const channelIds = (Array.isArray(rawChannels) ? rawChannels : [rawChannels]).flatMap((item) => item.split(",")).map((item) => item.trim()).filter(Boolean);
|
|
13204
13459
|
const platforms = (options.to ?? "").split(",").map((value2) => value2.trim()).filter(Boolean).map(parsePlatform);
|
|
13205
|
-
if (platforms.length > 0 &&
|
|
13460
|
+
if (platforms.length > 0 && channelIds.length > 0) failUsage("Use --to or --channel, not both.");
|
|
13461
|
+
const resolvedPlatforms = platforms.length > 0 ? platforms : channelIds.length === 0 && defaultPlatforms && defaultPlatforms.length > 0 ? defaultPlatforms.map(parsePlatform) : void 0;
|
|
13206
13462
|
return {
|
|
13207
|
-
platforms:
|
|
13208
|
-
selectedIntegrations:
|
|
13463
|
+
platforms: resolvedPlatforms,
|
|
13464
|
+
selectedIntegrations: channelIds.length > 0 ? channelIds : void 0
|
|
13209
13465
|
};
|
|
13210
13466
|
}
|
|
13211
13467
|
function readCopy(pairs) {
|
|
@@ -13244,22 +13500,24 @@ function printState(state, verb) {
|
|
|
13244
13500
|
printJson(state);
|
|
13245
13501
|
return;
|
|
13246
13502
|
}
|
|
13247
|
-
|
|
13503
|
+
printSuccess(
|
|
13248
13504
|
`${state.dryRun ? `Would ${verb.toLowerCase()}` : verb} ${state.postId}${state.review ? " (waiting for review)" : ""}`
|
|
13249
13505
|
);
|
|
13250
13506
|
for (const schedule of state.schedules) {
|
|
13251
13507
|
printLine(
|
|
13252
|
-
` ${schedule.platform.toLowerCase()} ${schedule.channelName} ${schedule.status.toLowerCase()} ${schedule.scheduledAt ?? "\u2014"} ${schedule.scheduleId}`
|
|
13508
|
+
` ${schedule.platform.toLowerCase().padEnd(10)} ${schedule.channelName.padEnd(18)} ${schedule.status.toLowerCase().padEnd(10)} ${schedule.scheduledAt ?? "\u2014"} ${schedule.scheduleId}`
|
|
13253
13509
|
);
|
|
13254
13510
|
}
|
|
13255
|
-
if (!state.dryRun) printStatus(
|
|
13511
|
+
if (!state.dryRun) printStatus(`
|
|
13512
|
+
Post URL: ${state.url}`);
|
|
13256
13513
|
}
|
|
13257
13514
|
async function post(text, options) {
|
|
13258
13515
|
const thread = options.threadFile ? await readThread(options.threadFile) : void 0;
|
|
13259
13516
|
const content = thread ? void 0 : await readContent(text, options);
|
|
13260
13517
|
if (!thread && !content) failUsage("No content. Pass text, --file, --thread-file, --editor, or pipe it in.");
|
|
13261
13518
|
const timing = readTiming(options);
|
|
13262
|
-
const
|
|
13519
|
+
const project = await readProjectConfig();
|
|
13520
|
+
const targets = readTargets(options, project?.defaultPlatforms);
|
|
13263
13521
|
if (timing.postAction !== "DRAFT" && !targets.platforms && !targets.selectedIntegrations) {
|
|
13264
13522
|
failUsage("Say where to post: --to x,linkedin or --channel <id> (or use --draft).");
|
|
13265
13523
|
}
|
|
@@ -13281,6 +13539,15 @@ async function post(text, options) {
|
|
|
13281
13539
|
const created = posts[0];
|
|
13282
13540
|
if (!created) return fail("The server created no post.");
|
|
13283
13541
|
printState(created, timing.postAction === "DRAFT" ? "Saved draft" : "Scheduled");
|
|
13542
|
+
if (!options.dryRun) {
|
|
13543
|
+
if (timing.postAction === "DRAFT") {
|
|
13544
|
+
printStatus(`
|
|
13545
|
+
Next: schedule this draft when ready:
|
|
13546
|
+
postonus queue schedule ${created.postId} --optimal`);
|
|
13547
|
+
} else {
|
|
13548
|
+
printStatus("\nNext: inspect your queue:\n postonus queue list");
|
|
13549
|
+
}
|
|
13550
|
+
}
|
|
13284
13551
|
} catch (error2) {
|
|
13285
13552
|
failApi(error2);
|
|
13286
13553
|
}
|
|
@@ -13313,6 +13580,34 @@ async function editPost(postId, text, options) {
|
|
|
13313
13580
|
}
|
|
13314
13581
|
}
|
|
13315
13582
|
async function deletePost(postId, options) {
|
|
13583
|
+
const confirmed = options.yes || hasConsent();
|
|
13584
|
+
if (!confirmed) {
|
|
13585
|
+
if (!isInteractive()) {
|
|
13586
|
+
failWith(
|
|
13587
|
+
{
|
|
13588
|
+
code: "BAD_REQUEST",
|
|
13589
|
+
status: "action_required",
|
|
13590
|
+
reason: "missing_consent",
|
|
13591
|
+
message: `Cannot delete post ${postId} in non-interactive mode without confirmation.`,
|
|
13592
|
+
next: [
|
|
13593
|
+
{
|
|
13594
|
+
command: `postonus post delete ${postId}${options.remote ? " --remote" : ""} --yes`,
|
|
13595
|
+
argv: ["postonus", "post", "delete", postId, ...options.remote ? ["--remote"] : [], "--yes"],
|
|
13596
|
+
when: "Confirm deletion of post and schedules"
|
|
13597
|
+
}
|
|
13598
|
+
],
|
|
13599
|
+
data: { violations: [{ message: "Pass -y or --yes to confirm deletion in non-interactive mode." }] }
|
|
13600
|
+
},
|
|
13601
|
+
EXIT.usage
|
|
13602
|
+
);
|
|
13603
|
+
}
|
|
13604
|
+
const message = options.remote ? `Delete post ${postId} and remove copies from platforms? This cannot be undone.` : `Delete post ${postId} and every scheduled copy in your workspace?`;
|
|
13605
|
+
const ok = await confirmPrompt(message);
|
|
13606
|
+
if (!ok) {
|
|
13607
|
+
printStatus("Canceled.");
|
|
13608
|
+
process.exit(EXIT.canceled);
|
|
13609
|
+
}
|
|
13610
|
+
}
|
|
13316
13611
|
const { api } = await getApi();
|
|
13317
13612
|
try {
|
|
13318
13613
|
const state = await api.posts.delete({ id: postId, deleteRemote: options.remote ?? false });
|
|
@@ -13320,7 +13615,7 @@ async function deletePost(postId, options) {
|
|
|
13320
13615
|
printJson(state);
|
|
13321
13616
|
return;
|
|
13322
13617
|
}
|
|
13323
|
-
|
|
13618
|
+
printSuccess(`Deleted ${postId}${state.deletedFromPlatforms ? ", and on its platforms" : ""}`);
|
|
13324
13619
|
} catch (error2) {
|
|
13325
13620
|
failApi(error2);
|
|
13326
13621
|
}
|
|
@@ -13336,8 +13631,9 @@ async function retrySchedule(scheduleId, options) {
|
|
|
13336
13631
|
async function bestTimes(options) {
|
|
13337
13632
|
const platforms = (options.to ?? "").split(",").map((value2) => value2.trim()).filter(Boolean).map(parsePlatform);
|
|
13338
13633
|
if (platforms.length === 0) failUsage("Which platforms? e.g. --to x,linkedin");
|
|
13339
|
-
const
|
|
13340
|
-
|
|
13634
|
+
const countStr = options.limit ?? options.count ?? "5";
|
|
13635
|
+
const count = Number.parseInt(countStr, 10);
|
|
13636
|
+
if (!Number.isInteger(count) || count < 1 || count > 20) failUsage("--limit must be between 1 and 20.");
|
|
13341
13637
|
const { api } = await getApi();
|
|
13342
13638
|
try {
|
|
13343
13639
|
const result = await api.platforms.bestTimes({ platforms, count });
|
|
@@ -13420,15 +13716,22 @@ async function listQueue(options) {
|
|
|
13420
13716
|
return;
|
|
13421
13717
|
}
|
|
13422
13718
|
if (schedules.length === 0) {
|
|
13423
|
-
|
|
13719
|
+
if (isJsonMode()) {
|
|
13720
|
+
printJson({ queue: [] });
|
|
13721
|
+
return;
|
|
13722
|
+
}
|
|
13723
|
+
printStatus(
|
|
13724
|
+
'No posts found in queue.\n\nSchedule your first post:\n postonus post "Hello world" --to x,linkedin --optimal'
|
|
13725
|
+
);
|
|
13424
13726
|
return;
|
|
13425
13727
|
}
|
|
13728
|
+
const isTty = process.stdout.isTTY;
|
|
13426
13729
|
const rows = schedules.map((schedule) => [
|
|
13427
|
-
formatWhen(schedule.scheduledAt),
|
|
13730
|
+
isTty ? formatWhen(schedule.scheduledAt) : schedule.scheduledAt ?? "\u2014",
|
|
13428
13731
|
schedule.integration.platform.toLowerCase(),
|
|
13429
13732
|
schedule.integration.name,
|
|
13430
13733
|
schedule.status.toLowerCase(),
|
|
13431
|
-
truncate(schedule.post.content),
|
|
13734
|
+
isTty ? truncate(schedule.post.content) : schedule.post.content.replace(WHITESPACE_RUN_REGEX, " ").trim(),
|
|
13432
13735
|
schedule.id
|
|
13433
13736
|
]);
|
|
13434
13737
|
if (isInteractive()) {
|
|
@@ -13455,7 +13758,10 @@ async function scheduleDraft(postId, options) {
|
|
|
13455
13758
|
return;
|
|
13456
13759
|
}
|
|
13457
13760
|
const when = state.schedules.find((schedule) => schedule.scheduledAt)?.scheduledAt;
|
|
13458
|
-
|
|
13761
|
+
printSuccess(`${state.dryRun ? "Would schedule" : "Scheduled"} ${postId} for ${when ?? "its next window"}`);
|
|
13762
|
+
if (!state.dryRun) {
|
|
13763
|
+
printStatus("\nNext: inspect your queue:\n postonus queue list");
|
|
13764
|
+
}
|
|
13459
13765
|
} catch (error2) {
|
|
13460
13766
|
failApi(error2);
|
|
13461
13767
|
}
|
|
@@ -13469,7 +13775,7 @@ async function moveQueueItem(scheduleId, options) {
|
|
|
13469
13775
|
printJson(state);
|
|
13470
13776
|
return;
|
|
13471
13777
|
}
|
|
13472
|
-
|
|
13778
|
+
printSuccess(`Moved ${scheduleId} to ${scheduledAt}`);
|
|
13473
13779
|
} catch (error2) {
|
|
13474
13780
|
failApi(error2);
|
|
13475
13781
|
}
|
|
@@ -13477,19 +13783,34 @@ async function moveQueueItem(scheduleId, options) {
|
|
|
13477
13783
|
|
|
13478
13784
|
// src/commands/workspaces.ts
|
|
13479
13785
|
async function listWorkspaces() {
|
|
13480
|
-
const { api } = await getApi();
|
|
13786
|
+
const { api, workspaceId } = await getApi();
|
|
13481
13787
|
try {
|
|
13482
13788
|
const workspaces = await api.workspace.list();
|
|
13483
13789
|
if (isJsonMode()) {
|
|
13484
|
-
printJson({
|
|
13790
|
+
printJson({
|
|
13791
|
+
activeWorkspaceId: workspaceId ?? null,
|
|
13792
|
+
workspaces: workspaces.map(({ id, name, role }) => ({
|
|
13793
|
+
id,
|
|
13794
|
+
name,
|
|
13795
|
+
role,
|
|
13796
|
+
active: id === workspaceId
|
|
13797
|
+
}))
|
|
13798
|
+
});
|
|
13485
13799
|
return;
|
|
13486
13800
|
}
|
|
13487
13801
|
printLine(
|
|
13488
13802
|
formatTable(
|
|
13489
|
-
["NAME", "ROLE", "ID"],
|
|
13490
|
-
workspaces.map((w) => [w.name, w.role, w.id])
|
|
13803
|
+
["NAME", "ROLE", "ID", "STATUS"],
|
|
13804
|
+
workspaces.map((w) => [w.name, w.role, w.id, w.id === workspaceId ? "linked/active" : ""])
|
|
13491
13805
|
)
|
|
13492
13806
|
);
|
|
13807
|
+
if (workspaceId) {
|
|
13808
|
+
const active = workspaces.find((w) => w.id === workspaceId);
|
|
13809
|
+
if (active) {
|
|
13810
|
+
printStatus(`
|
|
13811
|
+
Active workspace: ${active.name} (${active.id})`);
|
|
13812
|
+
}
|
|
13813
|
+
}
|
|
13493
13814
|
} catch (error2) {
|
|
13494
13815
|
failApi(error2);
|
|
13495
13816
|
}
|
|
@@ -13500,7 +13821,7 @@ var program = new Command();
|
|
|
13500
13821
|
program.exitOverride((error2) => {
|
|
13501
13822
|
process.exit(error2.exitCode === 0 ? EXIT.ok : EXIT.usage);
|
|
13502
13823
|
});
|
|
13503
|
-
program.name("postonus").description("Schedule and publish social posts from your terminal").version(CLI_VERSION, "-v, --version").option("--json", "output machine-readable JSON on stdout").option("-q, --quiet", "suppress progress output on stderr").option("--no-color", "disable coloured output").option("--
|
|
13824
|
+
program.name("postonus").description("Schedule and publish social posts from your terminal").version(CLI_VERSION, "-v, --version").option("--json", "output machine-readable JSON on stdout").option("-q, --quiet", "suppress progress output on stderr").option("--no-color", "disable coloured output").option("-d, --debug", "print debug diagnostics on stderr").option("-y, --yes", "grant consent for destructive or non-interactive actions").option("-t, --token <token>", "API key or token override; takes precedence over login").option("--non-interactive", "never prompt; fail instead of waiting for input").option("--no-input", "alias for --non-interactive").option("-w, --workspace <id>", "workspace to act in (from `postonus workspaces list`); sent as x-workspace-id").addHelpText(
|
|
13504
13825
|
"after",
|
|
13505
13826
|
`
|
|
13506
13827
|
Environment:
|
|
@@ -13512,11 +13833,12 @@ Environment:
|
|
|
13512
13833
|
Times are RFC 3339 with an offset: 2026-08-01T09:30:00Z or 2026-08-01T11:30:00+02:00.
|
|
13513
13834
|
|
|
13514
13835
|
Exit codes:
|
|
13515
|
-
0 ok, 1 other failure, 2 usage or validation, 3 auth, 4 plan or quota, 5 rate limit.
|
|
13836
|
+
0 ok, 1 other failure, 2 usage or validation, 3 auth, 4 plan or quota, 5 rate limit, 130 canceled.
|
|
13516
13837
|
With --json a failure prints { code, message, data: { violations } } on stdout.
|
|
13517
13838
|
|
|
13518
13839
|
Examples:
|
|
13519
13840
|
$ postonus login
|
|
13841
|
+
$ postonus link
|
|
13520
13842
|
$ postonus post "shipping today" --to x,linkedin --optimal
|
|
13521
13843
|
$ postonus post --file notes.md --to linkedin --at 2026-08-01T09:30:00Z
|
|
13522
13844
|
$ postonus post --thread-file thread.md --channel <id> --at 2026-08-01T09:30:00Z --dry-run
|
|
@@ -13528,21 +13850,25 @@ MCP:
|
|
|
13528
13850
|
"postonus": { "command": "postonus", "args": ["mcp"] }
|
|
13529
13851
|
It reuses this machine's stored login \u2014 the editor runs no OAuth of its own.`
|
|
13530
13852
|
).hook("preAction", (command) => {
|
|
13531
|
-
|
|
13853
|
+
const opts = command.opts();
|
|
13854
|
+
if (opts.input === false) opts.nonInteractive = true;
|
|
13855
|
+
setGlobalOptions(opts);
|
|
13532
13856
|
});
|
|
13533
13857
|
program.command("login").description("sign in via your browser").action(login);
|
|
13534
13858
|
program.command("logout").description("remove the stored credentials").action(logout);
|
|
13535
13859
|
program.command("whoami").description("show the signed-in account").action(whoami);
|
|
13536
|
-
var channels = program.command("channels").description("manage connected channels");
|
|
13860
|
+
var channels = program.command("channels").alias("channel").description("manage connected channels");
|
|
13537
13861
|
channels.command("list").alias("ls").description("list connected channels").action(listChannels);
|
|
13538
13862
|
channels.command("connect").description("connect a new channel via OAuth").option("-p, --platform <platform>", "platform to connect (prompts when omitted)").option("--no-wait", "return immediately instead of waiting for approval").action(connectChannel);
|
|
13863
|
+
program.command("link").description("link current directory to a Postonus workspace").option("-w, --workspace <id>", "workspace to link to").action(linkWorkspace);
|
|
13864
|
+
program.command("unlink").description("unlink current directory from its Postonus workspace").action(unlinkWorkspace);
|
|
13539
13865
|
var collect = (value2, previous = []) => [...previous, value2];
|
|
13540
|
-
var postCommand = program.command("post").description("create a post: scheduled, now, at the next optimal time, or as a draft").argument("[text]", "post content; also accepts piped stdin").option("-t, --to <platforms>", "comma-separated platforms, e.g. x,linkedin").option("-c, --channel <id>", "a channel id from `postonus channels list`; repeatable", collect).option("-a, --at <time>", "RFC 3339 time with an offset").option("-o, --optimal", "the next recommended window").option("--now", "publish as soon as the queue picks it up").option("-d, --draft", "save as a draft without scheduling").option("-f, --file <path>", "read content from a file").option("--thread-file <path>", "read a thread: segments separated by a line of ---").option("-e, --editor", "compose in $EDITOR").option("-m, --media <path...>", "attach local image or video files").option("--copy <channelId=text>", "text that replaces the body on one channel; repeatable", collect).option("--dry-run", "run every server check and show the result without saving").action(post);
|
|
13541
|
-
postCommand.command("edit").description("change a post; only the flags given change").argument("<postId>", "post id from `postonus queue list`").argument("[text]", "new content").option("-t, --to <platforms>", "replace the channels with these platforms").option("-c, --channel <id>", "replace the channels with these ids; repeatable", collect).option("-a, --at <time>", "move every channel to this RFC 3339 time").option("-f, --file <path>", "read new content from a file").option("--thread-file <path>", "replace the body with a thread file").option("-m, --media <path...>", "replace the media with these files").option("--copy <channelId=text>", "replace one channel's copy; repeatable", collect).option("--dry-run", "run every server check and show the result without saving").action(editPost);
|
|
13542
|
-
postCommand.command("delete").description("delete a post and every schedule on it").argument("<postId>", "post id from `postonus queue list`").option("--remote", "also delete published copies on their platforms").action(deletePost);
|
|
13866
|
+
var postCommand = program.command("post").alias("posts").description("create a post: scheduled, now, at the next optimal time, or as a draft").argument("[text]", "post content; also accepts piped stdin").option("-t, --to <platforms>", "comma-separated platforms, e.g. x,linkedin").option("-c, --channel <id>", "a channel id from `postonus channels list`; repeatable", collect).option("--channels <ids>", "channel ids; comma-separated or repeatable", collect).option("-a, --at <time>", "RFC 3339 time with an offset").option("-o, --optimal", "the next recommended window").option("--now", "publish as soon as the queue picks it up").option("-d, --draft", "save as a draft without scheduling").option("-f, --file <path>", "read content from a file").option("--thread-file <path>", "read a thread: segments separated by a line of ---").option("-e, --editor", "compose in $EDITOR").option("-m, --media <path...>", "attach local image or video files").option("--copy <channelId=text>", "text that replaces the body on one channel; repeatable", collect).option("--dry-run", "run every server check and show the result without saving").action(post);
|
|
13867
|
+
postCommand.command("edit").description("change a post; only the flags given change").argument("<postId>", "post id from `postonus queue list`").argument("[text]", "new content").option("-t, --to <platforms>", "replace the channels with these platforms").option("-c, --channel <id>", "replace the channels with these ids; repeatable", collect).option("--channels <ids>", "alias for --channel", collect).option("-a, --at <time>", "move every channel to this RFC 3339 time").option("-f, --file <path>", "read new content from a file").option("--thread-file <path>", "replace the body with a thread file").option("-m, --media <path...>", "replace the media with these files").option("--copy <channelId=text>", "replace one channel's copy; repeatable", collect).option("--dry-run", "run every server check and show the result without saving").action(editPost);
|
|
13868
|
+
postCommand.command("delete").alias("rm").alias("del").description("delete a post and every schedule on it").argument("<postId>", "post id from `postonus queue list`").option("--remote", "also delete published copies on their platforms").option("-y, --yes", "skip confirmation prompt").action(deletePost);
|
|
13543
13869
|
postCommand.command("retry").description("queue a failed schedule to publish again").argument("<scheduleId>", "schedule id from `postonus queue list --status failed`").option("--content <text>", "replacement copy for this channel only").action(retrySchedule);
|
|
13544
|
-
program.command("best-times").description("recommended posting windows for the given platforms").requiredOption("-t, --to <platforms>", "comma-separated platforms, e.g. x,linkedin").option("-n, --
|
|
13545
|
-
program.command("workspaces").description("workspaces you belong to").command("list").alias("ls").description("list workspaces and their ids").action(listWorkspaces);
|
|
13870
|
+
program.command("best-times").description("recommended posting windows for the given platforms").requiredOption("-t, --to <platforms>", "comma-separated platforms, e.g. x,linkedin").option("-n, --limit <count>", "how many times to list (1-20)", "5").option("--count <count>", "alias for --limit (deprecated)").action(bestTimes);
|
|
13871
|
+
program.command("workspaces").alias("workspace").description("workspaces you belong to").command("list").alias("ls").description("list workspaces and their ids").action(listWorkspaces);
|
|
13546
13872
|
var queue = program.command("queue").description("inspect and adjust scheduled posts");
|
|
13547
13873
|
queue.command("list").alias("ls").description("list drafts, scheduled posts and failures").addOption(new Option("-n, --limit <count>", "how many to show (10-100)").default("20")).option("-t, --to <platforms>", "filter by comma-separated platforms").option("-s, --status <statuses>", "filter by comma-separated statuses").action(listQueue);
|
|
13548
13874
|
queue.command("schedule").description("give a draft its send time").argument("<postId>", "post id from `postonus queue list --status draft` or `postonus post --draft`").option("-a, --at <time>", "RFC 3339 time with an offset").option("-o, --optimal", "next recommended window").option("--dry-run", "run every server check and show the result without saving").option(
|