@postonus/cli 0.1.32 → 0.1.34
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 +388 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -236,6 +236,9 @@ var isValidTimezone = (timezone) => {
|
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
238
|
|
|
239
|
+
// ../../packages/app-config/src/posting-for.ts
|
|
240
|
+
var POSTING_FOR_VALUES = ["product", "clients", "myself", "brand"];
|
|
241
|
+
|
|
239
242
|
// src/index.ts
|
|
240
243
|
import { Command, Option } from "commander";
|
|
241
244
|
|
|
@@ -9392,7 +9395,9 @@ var MeSchema = object({
|
|
|
9392
9395
|
emailVerified: boolean2(),
|
|
9393
9396
|
createdAt: Timestamp,
|
|
9394
9397
|
updatedAt: Timestamp,
|
|
9395
|
-
defaultOrganizationId: string2().nullable()
|
|
9398
|
+
defaultOrganizationId: string2().nullable(),
|
|
9399
|
+
/** Who the user posts for. Null until they answer the one onboarding question. */
|
|
9400
|
+
postingFor: _enum(POSTING_FOR_VALUES).nullable()
|
|
9396
9401
|
});
|
|
9397
9402
|
var UserAccountSchema = object({
|
|
9398
9403
|
id: string2(),
|
|
@@ -9518,7 +9523,8 @@ var userContract = {
|
|
|
9518
9523
|
resetPreferences: internal10.route({ method: "DELETE", path: "/users/me/preferences", summary: "Reset the current user's preferences" }).errors(authedErrors).output(object({ message: string2() })),
|
|
9519
9524
|
getPlanQuota: tagged19.route({ method: "GET", path: "/users/me/plan-quota", summary: "Get the active workspace's plan quota" }).errors(orgErrors).input(object({ platforms: array(PlatformEnum).optional() })).output(PlanQuotaSchema),
|
|
9520
9525
|
getAiQuota: internal10.route({ method: "GET", path: "/users/me/ai-quota", summary: "Get the active workspace's AI credit quota" }).errors(orgErrors).output(AiQuotaSchema),
|
|
9521
|
-
setDefaultWorkspace: internal10.route({ method: "POST", path: "/users/me/default-workspace", summary: "Set the current user's default workspace" }).errors({ ...authedErrors, FORBIDDEN: { message: "You are not a member of this workspace." } }).input(object({ organizationId: string2() })).output(DeletedSchema)
|
|
9526
|
+
setDefaultWorkspace: internal10.route({ method: "POST", path: "/users/me/default-workspace", summary: "Set the current user's default workspace" }).errors({ ...authedErrors, FORBIDDEN: { message: "You are not a member of this workspace." } }).input(object({ organizationId: string2() })).output(DeletedSchema),
|
|
9527
|
+
setPostingFor: internal10.route({ method: "PUT", path: "/users/me/posting-for", summary: "Answer who the current user posts for" }).errors(authedErrors).input(object({ postingFor: _enum(POSTING_FOR_VALUES) })).output(SuccessSchema)
|
|
9522
9528
|
};
|
|
9523
9529
|
|
|
9524
9530
|
// ../../packages/api-contract/src/workspace.ts
|
|
@@ -12199,7 +12205,7 @@ var schemaConverters = [new ZodToJsonSchemaConverter()];
|
|
|
12199
12205
|
var generator = new OpenAPIGenerator({ schemaConverters });
|
|
12200
12206
|
|
|
12201
12207
|
// src/config.ts
|
|
12202
|
-
import { chmod, mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
12208
|
+
import { chmod, mkdir, readFile, rm, stat, writeFile } from "fs/promises";
|
|
12203
12209
|
import { homedir } from "os";
|
|
12204
12210
|
import { dirname, join } from "path";
|
|
12205
12211
|
var DEFAULT_API_URL = "https://app.postonus.com";
|
|
@@ -12250,12 +12256,68 @@ async function clearConfig() {
|
|
|
12250
12256
|
function resolveApiUrl(config2) {
|
|
12251
12257
|
return (process.env[CLI_API_URL_ENV] || config2.apiUrl || DEFAULT_API_URL).replace(/\/$/, "");
|
|
12252
12258
|
}
|
|
12253
|
-
function resolveApiKey() {
|
|
12254
|
-
return process.env[CLI_API_KEY_ENV] || void 0;
|
|
12259
|
+
function resolveApiKey(cliToken) {
|
|
12260
|
+
return cliToken || process.env[CLI_API_KEY_ENV] || process.env.POSTONUS_TOKEN || void 0;
|
|
12261
|
+
}
|
|
12262
|
+
async function findProjectConfigDir(startDir = process.cwd()) {
|
|
12263
|
+
let current = startDir;
|
|
12264
|
+
while (true) {
|
|
12265
|
+
const candidate = join(current, ".postonus", "config.json");
|
|
12266
|
+
try {
|
|
12267
|
+
const stats = await stat(candidate);
|
|
12268
|
+
if (stats.isFile()) return join(current, ".postonus");
|
|
12269
|
+
} catch {
|
|
12270
|
+
}
|
|
12271
|
+
const parent = dirname(current);
|
|
12272
|
+
if (parent === current) break;
|
|
12273
|
+
current = parent;
|
|
12274
|
+
}
|
|
12275
|
+
return null;
|
|
12276
|
+
}
|
|
12277
|
+
async function readProjectConfig(startDir = process.cwd()) {
|
|
12278
|
+
const dir = await findProjectConfigDir(startDir);
|
|
12279
|
+
if (!dir) return null;
|
|
12280
|
+
try {
|
|
12281
|
+
const raw = await readFile(join(dir, "config.json"), "utf8");
|
|
12282
|
+
const parsed = JSON.parse(raw);
|
|
12283
|
+
if (isRecord(parsed) && isString(parsed.workspaceId)) {
|
|
12284
|
+
return {
|
|
12285
|
+
workspaceId: parsed.workspaceId,
|
|
12286
|
+
workspaceName: isString(parsed.workspaceName) ? parsed.workspaceName : void 0,
|
|
12287
|
+
defaultPlatforms: Array.isArray(parsed.defaultPlatforms) ? parsed.defaultPlatforms.filter(isString) : void 0
|
|
12288
|
+
};
|
|
12289
|
+
}
|
|
12290
|
+
} catch {
|
|
12291
|
+
return null;
|
|
12292
|
+
}
|
|
12293
|
+
return null;
|
|
12294
|
+
}
|
|
12295
|
+
async function writeProjectConfig(config2, inDir = process.cwd()) {
|
|
12296
|
+
const dir = join(inDir, ".postonus");
|
|
12297
|
+
const path = join(dir, "config.json");
|
|
12298
|
+
await mkdir(dir, { recursive: true, mode: 493 });
|
|
12299
|
+
await writeFile(path, `${JSON.stringify(config2, null, 2)}
|
|
12300
|
+
`, { mode: 420 });
|
|
12301
|
+
return path;
|
|
12302
|
+
}
|
|
12303
|
+
async function clearProjectConfig(inDir = process.cwd()) {
|
|
12304
|
+
const dir = join(inDir, ".postonus");
|
|
12305
|
+
try {
|
|
12306
|
+
await rm(join(dir, "config.json"), { force: true });
|
|
12307
|
+
return true;
|
|
12308
|
+
} catch {
|
|
12309
|
+
return false;
|
|
12310
|
+
}
|
|
12311
|
+
}
|
|
12312
|
+
async function resolveWorkspaceId(cliWorkspace) {
|
|
12313
|
+
if (cliWorkspace) return cliWorkspace;
|
|
12314
|
+
if (process.env.POSTONUS_WORKSPACE) return process.env.POSTONUS_WORKSPACE;
|
|
12315
|
+
const project = await readProjectConfig();
|
|
12316
|
+
return project?.workspaceId;
|
|
12255
12317
|
}
|
|
12256
12318
|
|
|
12257
12319
|
// src/output.ts
|
|
12258
|
-
var EXIT = { ok: 0, failure: 1, usage: 2, auth: 3, plan: 4, rateLimited: 5 };
|
|
12320
|
+
var EXIT = { ok: 0, failure: 1, usage: 2, auth: 3, plan: 4, rateLimited: 5, canceled: 130 };
|
|
12259
12321
|
var globals = {};
|
|
12260
12322
|
function setGlobalOptions(options) {
|
|
12261
12323
|
globals = options;
|
|
@@ -12264,7 +12326,21 @@ function isJsonMode() {
|
|
|
12264
12326
|
return globals.json === true;
|
|
12265
12327
|
}
|
|
12266
12328
|
function isInteractive() {
|
|
12267
|
-
if (globals.json || globals.input === false) return false;
|
|
12329
|
+
if (globals.json || globals.input === false || globals.nonInteractive === true) return false;
|
|
12330
|
+
if (process.env.CI || process.env.CLAUDE_CODE || process.env.CURSOR_AGENT || process.env.CODEX_ENV) return false;
|
|
12331
|
+
return process.stdout.isTTY && process.stdin.isTTY;
|
|
12332
|
+
}
|
|
12333
|
+
function hasConsent() {
|
|
12334
|
+
return globals.yes === true;
|
|
12335
|
+
}
|
|
12336
|
+
function isDebug() {
|
|
12337
|
+
return globals.debug === true;
|
|
12338
|
+
}
|
|
12339
|
+
function tokenOption() {
|
|
12340
|
+
return globals.token;
|
|
12341
|
+
}
|
|
12342
|
+
function shouldUseColor() {
|
|
12343
|
+
if (globals.color === false || process.env.NO_COLOR) return false;
|
|
12268
12344
|
return process.stdout.isTTY;
|
|
12269
12345
|
}
|
|
12270
12346
|
function printJson(data) {
|
|
@@ -12280,6 +12356,26 @@ function printStatus(line) {
|
|
|
12280
12356
|
process.stderr.write(`${line}
|
|
12281
12357
|
`);
|
|
12282
12358
|
}
|
|
12359
|
+
var GLYPH = {
|
|
12360
|
+
success: "\u2713",
|
|
12361
|
+
warning: "!",
|
|
12362
|
+
error: "\u2717",
|
|
12363
|
+
prompt: "?"
|
|
12364
|
+
};
|
|
12365
|
+
function printSuccess(headline) {
|
|
12366
|
+
if (globals.quiet || globals.json) return;
|
|
12367
|
+
const symbol = shouldUseColor() ? `\x1B[32m${GLYPH.success}\x1B[0m` : GLYPH.success;
|
|
12368
|
+
process.stderr.write(`${symbol} ${headline}
|
|
12369
|
+
`);
|
|
12370
|
+
}
|
|
12371
|
+
function printDebug(message) {
|
|
12372
|
+
if (!globals.debug) return;
|
|
12373
|
+
process.stderr.write(`[debug] ${message}
|
|
12374
|
+
`);
|
|
12375
|
+
}
|
|
12376
|
+
function formatRow(label, value2) {
|
|
12377
|
+
return ` ${label.padEnd(14)} ${value2}`;
|
|
12378
|
+
}
|
|
12283
12379
|
function workspaceOption() {
|
|
12284
12380
|
return globals.workspace;
|
|
12285
12381
|
}
|
|
@@ -12288,7 +12384,7 @@ function exitCodeFor(error2, status) {
|
|
|
12288
12384
|
if (error2.code === "RATE_LIMITED" || status === 429) return EXIT.rateLimited;
|
|
12289
12385
|
if (PLAN_CODES.has(error2.code) || status === 402) return EXIT.plan;
|
|
12290
12386
|
if (error2.code === "UNAUTHORIZED" || status === 401) return EXIT.auth;
|
|
12291
|
-
if (status === 400) return EXIT.usage;
|
|
12387
|
+
if (status === 400 || error2.code === "BAD_REQUEST") return EXIT.usage;
|
|
12292
12388
|
return EXIT.failure;
|
|
12293
12389
|
}
|
|
12294
12390
|
function failWith(error2, exitCode) {
|
|
@@ -12296,11 +12392,29 @@ function failWith(error2, exitCode) {
|
|
|
12296
12392
|
process.stdout.write(`${JSON.stringify(error2, null, 2)}
|
|
12297
12393
|
`);
|
|
12298
12394
|
} else {
|
|
12299
|
-
|
|
12395
|
+
const symbol = shouldUseColor() ? `\x1B[31m${GLYPH.error}\x1B[0m` : GLYPH.error;
|
|
12396
|
+
process.stderr.write(`${symbol} ${error2.message}
|
|
12300
12397
|
`);
|
|
12301
|
-
if (error2.data.violations.length >
|
|
12302
|
-
for (const violation of error2.data.violations)
|
|
12398
|
+
if (error2.data.violations.length > 0) {
|
|
12399
|
+
for (const violation of error2.data.violations) {
|
|
12400
|
+
process.stderr.write(` - ${violation.message}
|
|
12303
12401
|
`);
|
|
12402
|
+
}
|
|
12403
|
+
}
|
|
12404
|
+
if (error2.context) {
|
|
12405
|
+
for (const [key, val] of Object.entries(error2.context)) {
|
|
12406
|
+
process.stderr.write(`${formatRow(key, val)}
|
|
12407
|
+
`);
|
|
12408
|
+
}
|
|
12409
|
+
}
|
|
12410
|
+
if (error2.next && error2.next.length > 0) {
|
|
12411
|
+
process.stderr.write("\n Next steps:\n");
|
|
12412
|
+
for (const action of error2.next) {
|
|
12413
|
+
if (action.when) process.stderr.write(` ${action.when}:
|
|
12414
|
+
`);
|
|
12415
|
+
process.stderr.write(` ${action.command}
|
|
12416
|
+
`);
|
|
12417
|
+
}
|
|
12304
12418
|
}
|
|
12305
12419
|
}
|
|
12306
12420
|
process.exit(exitCode);
|
|
@@ -12311,8 +12425,8 @@ function fail(message, exitCode = EXIT.failure) {
|
|
|
12311
12425
|
exitCode
|
|
12312
12426
|
);
|
|
12313
12427
|
}
|
|
12314
|
-
function failUsage(message) {
|
|
12315
|
-
return failWith({ code: "BAD_REQUEST", message, data: { violations: [{ message }] } }, EXIT.usage);
|
|
12428
|
+
function failUsage(message, next) {
|
|
12429
|
+
return failWith({ code: "BAD_REQUEST", message, next, data: { violations: [{ message }] } }, EXIT.usage);
|
|
12316
12430
|
}
|
|
12317
12431
|
var INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/i;
|
|
12318
12432
|
function parseInstant(value2, flag) {
|
|
@@ -12325,9 +12439,14 @@ function parseInstant(value2, flag) {
|
|
|
12325
12439
|
}
|
|
12326
12440
|
function requireInteractive(what) {
|
|
12327
12441
|
if (isInteractive()) return;
|
|
12328
|
-
fail(
|
|
12442
|
+
fail(
|
|
12443
|
+
`${what} needs an interactive terminal. Pass the required flags instead, or run without --json / --non-interactive.`
|
|
12444
|
+
);
|
|
12329
12445
|
}
|
|
12330
|
-
function formatTable(headers, rows) {
|
|
12446
|
+
function formatTable(headers, rows, isTty = process.stdout.isTTY) {
|
|
12447
|
+
if (!isTty) {
|
|
12448
|
+
return [headers.join(" "), ...rows.map((row) => row.join(" "))].join("\n");
|
|
12449
|
+
}
|
|
12331
12450
|
const widths = headers.map(
|
|
12332
12451
|
(header, index) => Math.max(header.length, ...rows.map((row) => (row[index] ?? "").length))
|
|
12333
12452
|
);
|
|
@@ -12336,7 +12455,7 @@ function formatTable(headers, rows) {
|
|
|
12336
12455
|
}
|
|
12337
12456
|
|
|
12338
12457
|
// src/version.ts
|
|
12339
|
-
var CLI_VERSION = "0.1.
|
|
12458
|
+
var CLI_VERSION = "0.1.34";
|
|
12340
12459
|
|
|
12341
12460
|
// src/client.ts
|
|
12342
12461
|
var DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
@@ -12400,8 +12519,21 @@ function persistRefreshedTokens(apiUrl, oauth) {
|
|
|
12400
12519
|
});
|
|
12401
12520
|
};
|
|
12402
12521
|
}
|
|
12403
|
-
function buildClient(apiUrl, auth) {
|
|
12522
|
+
function buildClient(apiUrl, auth, workspaceId) {
|
|
12404
12523
|
const oauth = auth.kind === "oauth" ? { accessToken: auth.accessToken, refreshToken: auth.refreshToken, clientId: auth.clientId } : null;
|
|
12524
|
+
const baseFetch = oauth ? createOAuthFetch(apiUrl, oauth, persistRefreshedTokens(apiUrl, oauth)) : (request, init) => fetch(request, init);
|
|
12525
|
+
const instrumentedFetch = async (request, init) => {
|
|
12526
|
+
if (!isDebug()) {
|
|
12527
|
+
return baseFetch(request, init);
|
|
12528
|
+
}
|
|
12529
|
+
const start = Date.now();
|
|
12530
|
+
printDebug(`-> ${request.method} ${request.url}`);
|
|
12531
|
+
const response = await baseFetch(request, init);
|
|
12532
|
+
const duration3 = Date.now() - start;
|
|
12533
|
+
const reqId = response.headers.get("x-request-id");
|
|
12534
|
+
printDebug(`<- ${response.status} ${response.statusText} (${duration3}ms)${reqId ? ` [request-id:${reqId}]` : ""}`);
|
|
12535
|
+
return response;
|
|
12536
|
+
};
|
|
12405
12537
|
const link = new OpenAPILink(contract, {
|
|
12406
12538
|
url: `${apiUrl}/api/v1`,
|
|
12407
12539
|
headers: () => {
|
|
@@ -12410,21 +12542,22 @@ function buildClient(apiUrl, auth) {
|
|
|
12410
12542
|
"x-postonus-client": "cli",
|
|
12411
12543
|
...auth.kind === "api-key" ? { "x-api-key": auth.apiKey } : { authorization: `Bearer ${oauth?.accessToken}` }
|
|
12412
12544
|
});
|
|
12413
|
-
const workspace = workspaceOption();
|
|
12545
|
+
const workspace = workspaceId || workspaceOption();
|
|
12414
12546
|
if (workspace) headers.set("x-workspace-id", workspace);
|
|
12415
12547
|
return Object.fromEntries(headers);
|
|
12416
12548
|
},
|
|
12417
|
-
fetch:
|
|
12549
|
+
fetch: instrumentedFetch
|
|
12418
12550
|
});
|
|
12419
12551
|
return createORPCClient(link);
|
|
12420
12552
|
}
|
|
12421
12553
|
async function getApi() {
|
|
12422
12554
|
const config2 = await readConfig();
|
|
12423
12555
|
const apiUrl = resolveApiUrl(config2);
|
|
12424
|
-
const apiKey = resolveApiKey();
|
|
12556
|
+
const apiKey = resolveApiKey(tokenOption());
|
|
12557
|
+
const workspaceId = await resolveWorkspaceId(workspaceOption());
|
|
12425
12558
|
if (apiKey) {
|
|
12426
12559
|
const auth2 = { kind: "api-key", apiKey };
|
|
12427
|
-
return { api: buildClient(apiUrl, auth2), apiUrl, auth: auth2, config: config2 };
|
|
12560
|
+
return { api: buildClient(apiUrl, auth2, workspaceId), apiUrl, auth: auth2, config: config2, workspaceId };
|
|
12428
12561
|
}
|
|
12429
12562
|
if (!config2.accessToken || !config2.refreshToken || !config2.clientId) {
|
|
12430
12563
|
fail(`Not signed in. Run \`postonus login\`, or set ${CLI_API_KEY_ENV} for non-interactive use.`);
|
|
@@ -12444,7 +12577,7 @@ async function getApi() {
|
|
|
12444
12577
|
}
|
|
12445
12578
|
}
|
|
12446
12579
|
const auth = { kind: "oauth", accessToken, refreshToken, clientId };
|
|
12447
|
-
return { api: buildClient(apiUrl, auth), apiUrl, auth, config: config2 };
|
|
12580
|
+
return { api: buildClient(apiUrl, auth, workspaceId), apiUrl, auth, config: config2, workspaceId };
|
|
12448
12581
|
}
|
|
12449
12582
|
function describeError(cause) {
|
|
12450
12583
|
if (cause instanceof ORPCError3) {
|
|
@@ -12467,9 +12600,25 @@ function describeError(cause) {
|
|
|
12467
12600
|
function failApi(cause) {
|
|
12468
12601
|
if (cause instanceof ORPCError3) {
|
|
12469
12602
|
const data = cause.data;
|
|
12603
|
+
const nextActions = [];
|
|
12604
|
+
if (cause.code === "UNAUTHORIZED") {
|
|
12605
|
+
nextActions.push({
|
|
12606
|
+
command: "postonus login",
|
|
12607
|
+
argv: ["postonus", "login"],
|
|
12608
|
+
when: "Re-authenticate your terminal session"
|
|
12609
|
+
});
|
|
12610
|
+
} else if (cause.code === "CONTENT_TOO_LONG") {
|
|
12611
|
+
nextActions.push({
|
|
12612
|
+
command: "postonus post --thread-file <path>",
|
|
12613
|
+
when: "Split long text into a thread"
|
|
12614
|
+
});
|
|
12615
|
+
}
|
|
12470
12616
|
const error2 = {
|
|
12471
12617
|
code: cause.code,
|
|
12472
12618
|
message: describeError(cause),
|
|
12619
|
+
status: cause.code === "BAD_REQUEST" || cause.code === "UNAUTHORIZED" ? "action_required" : "error",
|
|
12620
|
+
reason: cause.code.toLowerCase(),
|
|
12621
|
+
next: nextActions.length > 0 ? nextActions : void 0,
|
|
12473
12622
|
data: { violations: data?.violations ?? [] }
|
|
12474
12623
|
};
|
|
12475
12624
|
return failWith(error2, exitCodeFor(error2, cause.status));
|
|
@@ -12559,6 +12708,17 @@ async function renderOnce(node2) {
|
|
|
12559
12708
|
await instance.waitUntilRenderFlush();
|
|
12560
12709
|
instance.unmount();
|
|
12561
12710
|
}
|
|
12711
|
+
async function confirmPrompt(message) {
|
|
12712
|
+
const readline = await import("readline/promises");
|
|
12713
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
12714
|
+
try {
|
|
12715
|
+
const answer = await rl.question(`? ${message} (y/N) `);
|
|
12716
|
+
const normalized = answer.trim().toLowerCase();
|
|
12717
|
+
return normalized === "y" || normalized === "yes";
|
|
12718
|
+
} finally {
|
|
12719
|
+
rl.close();
|
|
12720
|
+
}
|
|
12721
|
+
}
|
|
12562
12722
|
|
|
12563
12723
|
// src/commands/auth.tsx
|
|
12564
12724
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -12810,7 +12970,7 @@ async function listChannels() {
|
|
|
12810
12970
|
return;
|
|
12811
12971
|
}
|
|
12812
12972
|
if (channels2.length === 0) {
|
|
12813
|
-
printStatus("No channels connected
|
|
12973
|
+
printStatus("No channels connected in this workspace.\n\nConnect a channel:\n postonus channels connect");
|
|
12814
12974
|
return;
|
|
12815
12975
|
}
|
|
12816
12976
|
const rows = channels2.map(toRow);
|
|
@@ -12914,7 +13074,103 @@ async function connectChannel(options) {
|
|
|
12914
13074
|
if (!added) {
|
|
12915
13075
|
fail("Timed out waiting for the channel to appear. Check `postonus channels list`.");
|
|
12916
13076
|
}
|
|
12917
|
-
|
|
13077
|
+
printSuccess(`Connected ${added.platform} \u2014 ${added.name} (${added.id})`);
|
|
13078
|
+
printStatus(
|
|
13079
|
+
`
|
|
13080
|
+
Next: schedule a post to this channel:
|
|
13081
|
+
postonus post "First post" --to ${added.platform.toLowerCase()}`
|
|
13082
|
+
);
|
|
13083
|
+
}
|
|
13084
|
+
|
|
13085
|
+
// src/commands/link.ts
|
|
13086
|
+
import { render as render4 } from "ink";
|
|
13087
|
+
import * as React3 from "react";
|
|
13088
|
+
async function linkWorkspace(options) {
|
|
13089
|
+
const { api } = await getApi();
|
|
13090
|
+
let workspaces = [];
|
|
13091
|
+
try {
|
|
13092
|
+
workspaces = await api.workspace.list();
|
|
13093
|
+
} catch (error2) {
|
|
13094
|
+
return fail(`Could not list workspaces: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
13095
|
+
}
|
|
13096
|
+
if (workspaces.length === 0) {
|
|
13097
|
+
return fail("No workspaces available for your account.");
|
|
13098
|
+
}
|
|
13099
|
+
let selectedId = options.workspace || workspaceOption();
|
|
13100
|
+
if (selectedId) {
|
|
13101
|
+
const match = workspaces.find((w) => w.id === selectedId || w.name.toLowerCase() === selectedId?.toLowerCase());
|
|
13102
|
+
if (!match) {
|
|
13103
|
+
failUsage(`Workspace "${selectedId}" not found. Available: ${workspaces.map((w) => w.id).join(", ")}`);
|
|
13104
|
+
}
|
|
13105
|
+
selectedId = match.id;
|
|
13106
|
+
} else {
|
|
13107
|
+
if (!isInteractive()) {
|
|
13108
|
+
failUsage("Missing workspace. Pass -w, --workspace <id> in non-interactive mode.");
|
|
13109
|
+
}
|
|
13110
|
+
if (workspaces.length === 1 && workspaces[0]) {
|
|
13111
|
+
selectedId = workspaces[0].id;
|
|
13112
|
+
} else {
|
|
13113
|
+
selectedId = await new Promise((resolve) => {
|
|
13114
|
+
const items = workspaces.map((w) => ({
|
|
13115
|
+
value: w.id,
|
|
13116
|
+
label: w.name,
|
|
13117
|
+
hint: w.role
|
|
13118
|
+
}));
|
|
13119
|
+
const instance = render4(
|
|
13120
|
+
React3.createElement(Select, {
|
|
13121
|
+
label: "Which workspace would you like to link to this directory?",
|
|
13122
|
+
items,
|
|
13123
|
+
onSelect: (val) => {
|
|
13124
|
+
instance.unmount();
|
|
13125
|
+
resolve(val ?? void 0);
|
|
13126
|
+
}
|
|
13127
|
+
})
|
|
13128
|
+
);
|
|
13129
|
+
});
|
|
13130
|
+
}
|
|
13131
|
+
}
|
|
13132
|
+
if (!selectedId) {
|
|
13133
|
+
printStatus("Canceled.");
|
|
13134
|
+
return;
|
|
13135
|
+
}
|
|
13136
|
+
const workspace = workspaces.find((w) => w.id === selectedId);
|
|
13137
|
+
if (!workspace) {
|
|
13138
|
+
return fail(`Workspace ${selectedId} is not available.`);
|
|
13139
|
+
}
|
|
13140
|
+
const path = await writeProjectConfig({
|
|
13141
|
+
workspaceId: workspace.id,
|
|
13142
|
+
workspaceName: workspace.name
|
|
13143
|
+
});
|
|
13144
|
+
if (isJsonMode()) {
|
|
13145
|
+
printJson({
|
|
13146
|
+
status: "linked",
|
|
13147
|
+
workspaceId: workspace.id,
|
|
13148
|
+
workspaceName: workspace.name,
|
|
13149
|
+
configPath: path
|
|
13150
|
+
});
|
|
13151
|
+
return;
|
|
13152
|
+
}
|
|
13153
|
+
printSuccess(`Linked directory to ${workspace.name} (${workspace.id})`);
|
|
13154
|
+
printStatus(
|
|
13155
|
+
"Configuration saved to .postonus/config.json\n\nNext: schedule posts or inspect queue:\n postonus queue list"
|
|
13156
|
+
);
|
|
13157
|
+
}
|
|
13158
|
+
async function unlinkWorkspace() {
|
|
13159
|
+
const current = await readProjectConfig();
|
|
13160
|
+
if (!current) {
|
|
13161
|
+
if (isJsonMode()) {
|
|
13162
|
+
printJson({ status: "not_linked" });
|
|
13163
|
+
return;
|
|
13164
|
+
}
|
|
13165
|
+
printStatus("This directory is not linked to any Postonus workspace.");
|
|
13166
|
+
return;
|
|
13167
|
+
}
|
|
13168
|
+
await clearProjectConfig();
|
|
13169
|
+
if (isJsonMode()) {
|
|
13170
|
+
printJson({ status: "unlinked", workspaceId: current.workspaceId });
|
|
13171
|
+
return;
|
|
13172
|
+
}
|
|
13173
|
+
printSuccess(`Unlinked directory from ${current.workspaceName || current.workspaceId}`);
|
|
12918
13174
|
}
|
|
12919
13175
|
|
|
12920
13176
|
// src/commands/mcp.ts
|
|
@@ -12953,7 +13209,7 @@ function parseIncoming(message) {
|
|
|
12953
13209
|
var write = (message) => process.stdout.write(`${message}
|
|
12954
13210
|
`);
|
|
12955
13211
|
async function mcpServe() {
|
|
12956
|
-
const { apiUrl, auth } = await getApi();
|
|
13212
|
+
const { apiUrl, auth, workspaceId } = await getApi();
|
|
12957
13213
|
const endpoint = `${apiUrl}/api/mcp`;
|
|
12958
13214
|
if (auth.kind === "oauth" && !tokenAudiences(auth.accessToken).includes(endpoint)) {
|
|
12959
13215
|
fail("This sign-in does not cover the MCP endpoint. Run `postonus login` again to grant it.");
|
|
@@ -12970,6 +13226,9 @@ async function mcpServe() {
|
|
|
12970
13226
|
accept: "application/json, text/event-stream",
|
|
12971
13227
|
[CLI_VERSION_HEADER]: CLI_VERSION
|
|
12972
13228
|
});
|
|
13229
|
+
if (workspaceId) {
|
|
13230
|
+
headers.set("x-workspace-id", workspaceId);
|
|
13231
|
+
}
|
|
12973
13232
|
if (currentAuth.kind === "api-key") {
|
|
12974
13233
|
headers.set("x-api-key", currentAuth.apiKey);
|
|
12975
13234
|
} else if (oauth?.accessToken) {
|
|
@@ -13024,7 +13283,7 @@ async function mcpServe() {
|
|
|
13024
13283
|
|
|
13025
13284
|
// src/commands/media.ts
|
|
13026
13285
|
import { createHash } from "crypto";
|
|
13027
|
-
import { open as openFile, stat } from "fs/promises";
|
|
13286
|
+
import { open as openFile, stat as stat2 } from "fs/promises";
|
|
13028
13287
|
import { basename, extname } from "path";
|
|
13029
13288
|
var SCENARIO = "post_attachments";
|
|
13030
13289
|
function contentTypeFor(path) {
|
|
@@ -13060,7 +13319,7 @@ async function putBytes(url2, body, headers) {
|
|
|
13060
13319
|
}
|
|
13061
13320
|
async function uploadMedia(api, path) {
|
|
13062
13321
|
const contentType = contentTypeFor(path);
|
|
13063
|
-
const info = await
|
|
13322
|
+
const info = await stat2(path).catch(() => {
|
|
13064
13323
|
fail(`No such file: ${path}`);
|
|
13065
13324
|
});
|
|
13066
13325
|
if (!info.isFile()) fail(`Not a file: ${path}`);
|
|
@@ -13200,12 +13459,15 @@ async function openEditor(initial) {
|
|
|
13200
13459
|
await rm2(directory, { recursive: true, force: true });
|
|
13201
13460
|
}
|
|
13202
13461
|
}
|
|
13203
|
-
function readTargets(options) {
|
|
13462
|
+
function readTargets(options, defaultPlatforms) {
|
|
13463
|
+
const rawChannels = options.channel ?? [];
|
|
13464
|
+
const channelIds = (Array.isArray(rawChannels) ? rawChannels : [rawChannels]).flatMap((item) => item.split(",")).map((item) => item.trim()).filter(Boolean);
|
|
13204
13465
|
const platforms = (options.to ?? "").split(",").map((value2) => value2.trim()).filter(Boolean).map(parsePlatform);
|
|
13205
|
-
if (platforms.length > 0 &&
|
|
13466
|
+
if (platforms.length > 0 && channelIds.length > 0) failUsage("Use --to or --channel, not both.");
|
|
13467
|
+
const resolvedPlatforms = platforms.length > 0 ? platforms : channelIds.length === 0 && defaultPlatforms && defaultPlatforms.length > 0 ? defaultPlatforms.map(parsePlatform) : void 0;
|
|
13206
13468
|
return {
|
|
13207
|
-
platforms:
|
|
13208
|
-
selectedIntegrations:
|
|
13469
|
+
platforms: resolvedPlatforms,
|
|
13470
|
+
selectedIntegrations: channelIds.length > 0 ? channelIds : void 0
|
|
13209
13471
|
};
|
|
13210
13472
|
}
|
|
13211
13473
|
function readCopy(pairs) {
|
|
@@ -13244,22 +13506,24 @@ function printState(state, verb) {
|
|
|
13244
13506
|
printJson(state);
|
|
13245
13507
|
return;
|
|
13246
13508
|
}
|
|
13247
|
-
|
|
13509
|
+
printSuccess(
|
|
13248
13510
|
`${state.dryRun ? `Would ${verb.toLowerCase()}` : verb} ${state.postId}${state.review ? " (waiting for review)" : ""}`
|
|
13249
13511
|
);
|
|
13250
13512
|
for (const schedule of state.schedules) {
|
|
13251
13513
|
printLine(
|
|
13252
|
-
` ${schedule.platform.toLowerCase()} ${schedule.channelName} ${schedule.status.toLowerCase()} ${schedule.scheduledAt ?? "\u2014"} ${schedule.scheduleId}`
|
|
13514
|
+
` ${schedule.platform.toLowerCase().padEnd(10)} ${schedule.channelName.padEnd(18)} ${schedule.status.toLowerCase().padEnd(10)} ${schedule.scheduledAt ?? "\u2014"} ${schedule.scheduleId}`
|
|
13253
13515
|
);
|
|
13254
13516
|
}
|
|
13255
|
-
if (!state.dryRun) printStatus(
|
|
13517
|
+
if (!state.dryRun) printStatus(`
|
|
13518
|
+
Post URL: ${state.url}`);
|
|
13256
13519
|
}
|
|
13257
13520
|
async function post(text, options) {
|
|
13258
13521
|
const thread = options.threadFile ? await readThread(options.threadFile) : void 0;
|
|
13259
13522
|
const content = thread ? void 0 : await readContent(text, options);
|
|
13260
13523
|
if (!thread && !content) failUsage("No content. Pass text, --file, --thread-file, --editor, or pipe it in.");
|
|
13261
13524
|
const timing = readTiming(options);
|
|
13262
|
-
const
|
|
13525
|
+
const project = await readProjectConfig();
|
|
13526
|
+
const targets = readTargets(options, project?.defaultPlatforms);
|
|
13263
13527
|
if (timing.postAction !== "DRAFT" && !targets.platforms && !targets.selectedIntegrations) {
|
|
13264
13528
|
failUsage("Say where to post: --to x,linkedin or --channel <id> (or use --draft).");
|
|
13265
13529
|
}
|
|
@@ -13281,6 +13545,15 @@ async function post(text, options) {
|
|
|
13281
13545
|
const created = posts[0];
|
|
13282
13546
|
if (!created) return fail("The server created no post.");
|
|
13283
13547
|
printState(created, timing.postAction === "DRAFT" ? "Saved draft" : "Scheduled");
|
|
13548
|
+
if (!options.dryRun) {
|
|
13549
|
+
if (timing.postAction === "DRAFT") {
|
|
13550
|
+
printStatus(`
|
|
13551
|
+
Next: schedule this draft when ready:
|
|
13552
|
+
postonus queue schedule ${created.postId} --optimal`);
|
|
13553
|
+
} else {
|
|
13554
|
+
printStatus("\nNext: inspect your queue:\n postonus queue list");
|
|
13555
|
+
}
|
|
13556
|
+
}
|
|
13284
13557
|
} catch (error2) {
|
|
13285
13558
|
failApi(error2);
|
|
13286
13559
|
}
|
|
@@ -13313,6 +13586,34 @@ async function editPost(postId, text, options) {
|
|
|
13313
13586
|
}
|
|
13314
13587
|
}
|
|
13315
13588
|
async function deletePost(postId, options) {
|
|
13589
|
+
const confirmed = options.yes || hasConsent();
|
|
13590
|
+
if (!confirmed) {
|
|
13591
|
+
if (!isInteractive()) {
|
|
13592
|
+
failWith(
|
|
13593
|
+
{
|
|
13594
|
+
code: "BAD_REQUEST",
|
|
13595
|
+
status: "action_required",
|
|
13596
|
+
reason: "missing_consent",
|
|
13597
|
+
message: `Cannot delete post ${postId} in non-interactive mode without confirmation.`,
|
|
13598
|
+
next: [
|
|
13599
|
+
{
|
|
13600
|
+
command: `postonus post delete ${postId}${options.remote ? " --remote" : ""} --yes`,
|
|
13601
|
+
argv: ["postonus", "post", "delete", postId, ...options.remote ? ["--remote"] : [], "--yes"],
|
|
13602
|
+
when: "Confirm deletion of post and schedules"
|
|
13603
|
+
}
|
|
13604
|
+
],
|
|
13605
|
+
data: { violations: [{ message: "Pass -y or --yes to confirm deletion in non-interactive mode." }] }
|
|
13606
|
+
},
|
|
13607
|
+
EXIT.usage
|
|
13608
|
+
);
|
|
13609
|
+
}
|
|
13610
|
+
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?`;
|
|
13611
|
+
const ok = await confirmPrompt(message);
|
|
13612
|
+
if (!ok) {
|
|
13613
|
+
printStatus("Canceled.");
|
|
13614
|
+
process.exit(EXIT.canceled);
|
|
13615
|
+
}
|
|
13616
|
+
}
|
|
13316
13617
|
const { api } = await getApi();
|
|
13317
13618
|
try {
|
|
13318
13619
|
const state = await api.posts.delete({ id: postId, deleteRemote: options.remote ?? false });
|
|
@@ -13320,7 +13621,7 @@ async function deletePost(postId, options) {
|
|
|
13320
13621
|
printJson(state);
|
|
13321
13622
|
return;
|
|
13322
13623
|
}
|
|
13323
|
-
|
|
13624
|
+
printSuccess(`Deleted ${postId}${state.deletedFromPlatforms ? ", and on its platforms" : ""}`);
|
|
13324
13625
|
} catch (error2) {
|
|
13325
13626
|
failApi(error2);
|
|
13326
13627
|
}
|
|
@@ -13336,8 +13637,9 @@ async function retrySchedule(scheduleId, options) {
|
|
|
13336
13637
|
async function bestTimes(options) {
|
|
13337
13638
|
const platforms = (options.to ?? "").split(",").map((value2) => value2.trim()).filter(Boolean).map(parsePlatform);
|
|
13338
13639
|
if (platforms.length === 0) failUsage("Which platforms? e.g. --to x,linkedin");
|
|
13339
|
-
const
|
|
13340
|
-
|
|
13640
|
+
const countStr = options.limit ?? options.count ?? "5";
|
|
13641
|
+
const count = Number.parseInt(countStr, 10);
|
|
13642
|
+
if (!Number.isInteger(count) || count < 1 || count > 20) failUsage("--limit must be between 1 and 20.");
|
|
13341
13643
|
const { api } = await getApi();
|
|
13342
13644
|
try {
|
|
13343
13645
|
const result = await api.platforms.bestTimes({ platforms, count });
|
|
@@ -13420,15 +13722,22 @@ async function listQueue(options) {
|
|
|
13420
13722
|
return;
|
|
13421
13723
|
}
|
|
13422
13724
|
if (schedules.length === 0) {
|
|
13423
|
-
|
|
13725
|
+
if (isJsonMode()) {
|
|
13726
|
+
printJson({ queue: [] });
|
|
13727
|
+
return;
|
|
13728
|
+
}
|
|
13729
|
+
printStatus(
|
|
13730
|
+
'No posts found in queue.\n\nSchedule your first post:\n postonus post "Hello world" --to x,linkedin --optimal'
|
|
13731
|
+
);
|
|
13424
13732
|
return;
|
|
13425
13733
|
}
|
|
13734
|
+
const isTty = process.stdout.isTTY;
|
|
13426
13735
|
const rows = schedules.map((schedule) => [
|
|
13427
|
-
formatWhen(schedule.scheduledAt),
|
|
13736
|
+
isTty ? formatWhen(schedule.scheduledAt) : schedule.scheduledAt ?? "\u2014",
|
|
13428
13737
|
schedule.integration.platform.toLowerCase(),
|
|
13429
13738
|
schedule.integration.name,
|
|
13430
13739
|
schedule.status.toLowerCase(),
|
|
13431
|
-
truncate(schedule.post.content),
|
|
13740
|
+
isTty ? truncate(schedule.post.content) : schedule.post.content.replace(WHITESPACE_RUN_REGEX, " ").trim(),
|
|
13432
13741
|
schedule.id
|
|
13433
13742
|
]);
|
|
13434
13743
|
if (isInteractive()) {
|
|
@@ -13455,7 +13764,10 @@ async function scheduleDraft(postId, options) {
|
|
|
13455
13764
|
return;
|
|
13456
13765
|
}
|
|
13457
13766
|
const when = state.schedules.find((schedule) => schedule.scheduledAt)?.scheduledAt;
|
|
13458
|
-
|
|
13767
|
+
printSuccess(`${state.dryRun ? "Would schedule" : "Scheduled"} ${postId} for ${when ?? "its next window"}`);
|
|
13768
|
+
if (!state.dryRun) {
|
|
13769
|
+
printStatus("\nNext: inspect your queue:\n postonus queue list");
|
|
13770
|
+
}
|
|
13459
13771
|
} catch (error2) {
|
|
13460
13772
|
failApi(error2);
|
|
13461
13773
|
}
|
|
@@ -13469,7 +13781,7 @@ async function moveQueueItem(scheduleId, options) {
|
|
|
13469
13781
|
printJson(state);
|
|
13470
13782
|
return;
|
|
13471
13783
|
}
|
|
13472
|
-
|
|
13784
|
+
printSuccess(`Moved ${scheduleId} to ${scheduledAt}`);
|
|
13473
13785
|
} catch (error2) {
|
|
13474
13786
|
failApi(error2);
|
|
13475
13787
|
}
|
|
@@ -13477,19 +13789,34 @@ async function moveQueueItem(scheduleId, options) {
|
|
|
13477
13789
|
|
|
13478
13790
|
// src/commands/workspaces.ts
|
|
13479
13791
|
async function listWorkspaces() {
|
|
13480
|
-
const { api } = await getApi();
|
|
13792
|
+
const { api, workspaceId } = await getApi();
|
|
13481
13793
|
try {
|
|
13482
13794
|
const workspaces = await api.workspace.list();
|
|
13483
13795
|
if (isJsonMode()) {
|
|
13484
|
-
printJson({
|
|
13796
|
+
printJson({
|
|
13797
|
+
activeWorkspaceId: workspaceId ?? null,
|
|
13798
|
+
workspaces: workspaces.map(({ id, name, role }) => ({
|
|
13799
|
+
id,
|
|
13800
|
+
name,
|
|
13801
|
+
role,
|
|
13802
|
+
active: id === workspaceId
|
|
13803
|
+
}))
|
|
13804
|
+
});
|
|
13485
13805
|
return;
|
|
13486
13806
|
}
|
|
13487
13807
|
printLine(
|
|
13488
13808
|
formatTable(
|
|
13489
|
-
["NAME", "ROLE", "ID"],
|
|
13490
|
-
workspaces.map((w) => [w.name, w.role, w.id])
|
|
13809
|
+
["NAME", "ROLE", "ID", "STATUS"],
|
|
13810
|
+
workspaces.map((w) => [w.name, w.role, w.id, w.id === workspaceId ? "linked/active" : ""])
|
|
13491
13811
|
)
|
|
13492
13812
|
);
|
|
13813
|
+
if (workspaceId) {
|
|
13814
|
+
const active = workspaces.find((w) => w.id === workspaceId);
|
|
13815
|
+
if (active) {
|
|
13816
|
+
printStatus(`
|
|
13817
|
+
Active workspace: ${active.name} (${active.id})`);
|
|
13818
|
+
}
|
|
13819
|
+
}
|
|
13493
13820
|
} catch (error2) {
|
|
13494
13821
|
failApi(error2);
|
|
13495
13822
|
}
|
|
@@ -13500,7 +13827,7 @@ var program = new Command();
|
|
|
13500
13827
|
program.exitOverride((error2) => {
|
|
13501
13828
|
process.exit(error2.exitCode === 0 ? EXIT.ok : EXIT.usage);
|
|
13502
13829
|
});
|
|
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("--
|
|
13830
|
+
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
13831
|
"after",
|
|
13505
13832
|
`
|
|
13506
13833
|
Environment:
|
|
@@ -13512,11 +13839,12 @@ Environment:
|
|
|
13512
13839
|
Times are RFC 3339 with an offset: 2026-08-01T09:30:00Z or 2026-08-01T11:30:00+02:00.
|
|
13513
13840
|
|
|
13514
13841
|
Exit codes:
|
|
13515
|
-
0 ok, 1 other failure, 2 usage or validation, 3 auth, 4 plan or quota, 5 rate limit.
|
|
13842
|
+
0 ok, 1 other failure, 2 usage or validation, 3 auth, 4 plan or quota, 5 rate limit, 130 canceled.
|
|
13516
13843
|
With --json a failure prints { code, message, data: { violations } } on stdout.
|
|
13517
13844
|
|
|
13518
13845
|
Examples:
|
|
13519
13846
|
$ postonus login
|
|
13847
|
+
$ postonus link
|
|
13520
13848
|
$ postonus post "shipping today" --to x,linkedin --optimal
|
|
13521
13849
|
$ postonus post --file notes.md --to linkedin --at 2026-08-01T09:30:00Z
|
|
13522
13850
|
$ postonus post --thread-file thread.md --channel <id> --at 2026-08-01T09:30:00Z --dry-run
|
|
@@ -13528,21 +13856,25 @@ MCP:
|
|
|
13528
13856
|
"postonus": { "command": "postonus", "args": ["mcp"] }
|
|
13529
13857
|
It reuses this machine's stored login \u2014 the editor runs no OAuth of its own.`
|
|
13530
13858
|
).hook("preAction", (command) => {
|
|
13531
|
-
|
|
13859
|
+
const opts = command.opts();
|
|
13860
|
+
if (opts.input === false) opts.nonInteractive = true;
|
|
13861
|
+
setGlobalOptions(opts);
|
|
13532
13862
|
});
|
|
13533
13863
|
program.command("login").description("sign in via your browser").action(login);
|
|
13534
13864
|
program.command("logout").description("remove the stored credentials").action(logout);
|
|
13535
13865
|
program.command("whoami").description("show the signed-in account").action(whoami);
|
|
13536
|
-
var channels = program.command("channels").description("manage connected channels");
|
|
13866
|
+
var channels = program.command("channels").alias("channel").description("manage connected channels");
|
|
13537
13867
|
channels.command("list").alias("ls").description("list connected channels").action(listChannels);
|
|
13538
13868
|
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);
|
|
13869
|
+
program.command("link").description("link current directory to a Postonus workspace").option("-w, --workspace <id>", "workspace to link to").action(linkWorkspace);
|
|
13870
|
+
program.command("unlink").description("unlink current directory from its Postonus workspace").action(unlinkWorkspace);
|
|
13539
13871
|
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);
|
|
13872
|
+
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);
|
|
13873
|
+
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);
|
|
13874
|
+
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
13875
|
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);
|
|
13876
|
+
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);
|
|
13877
|
+
program.command("workspaces").alias("workspace").description("workspaces you belong to").command("list").alias("ls").description("list workspaces and their ids").action(listWorkspaces);
|
|
13546
13878
|
var queue = program.command("queue").description("inspect and adjust scheduled posts");
|
|
13547
13879
|
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
13880
|
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(
|