|
1 | | ---- |
2 | | -layout: default |
3 | | -title: Unified CLI |
4 | | ---- |
5 | | - |
6 | | -# Unified CLI |
7 | | - |
8 | | -Global options such as `--json`, `--cookies`, and `--publication-url` must |
9 | | -appear before the command. |
10 | | - |
11 | | -## Create an unpublished draft |
12 | | - |
13 | | -```bash |
14 | | -substack drafts create post.md |
15 | | -``` |
16 | | - |
17 | | -The title comes from the first Markdown heading, then the filename if the file |
18 | | -has no heading. Use `--title` to override it. |
19 | | - |
20 | | -## Export a draft to Markdown |
21 | | - |
22 | | -Print a read-only Markdown backup to standard output: |
23 | | - |
24 | | -```bash |
25 | | -substack drafts export 12345 |
26 | | -``` |
27 | | - |
28 | | -Write it to a UTF-8 file: |
29 | | - |
30 | | -```bash |
31 | | -substack drafts export 12345 --output backup.md |
32 | | -``` |
33 | | - |
34 | | -The command refuses to replace an existing file unless `--force` is present. |
35 | | -It fetches the draft but performs no server writes. Content without a supported |
36 | | -Markdown representation is emitted as a versioned opaque HTML comment instead |
37 | | -of being silently discarded. |
38 | | - |
39 | | -## Update a draft from Markdown |
40 | | - |
41 | | -Preview the generated update without writing to Substack: |
42 | | - |
43 | | -```bash |
44 | | -substack drafts update 12345 revised-post.md --dry-run --yes |
45 | | -``` |
46 | | - |
47 | | -Apply it after review: |
48 | | - |
49 | | -```bash |
50 | | -substack drafts update 12345 revised-post.md --yes |
51 | | -``` |
52 | | - |
53 | | -Updates preserve unsupported editor nodes exported as |
54 | | -`python-substack-node:v1` markers. The command refuses to remove or alter |
55 | | -those nodes by default. `--allow-unsupported-change` is available only with |
56 | | -`--yes` for an intentional destructive change. The CLI uses its authenticated |
57 | | -API client while rendering, so local images can upload even during a dry run. |
58 | | - |
59 | | -## Select a publication |
60 | | - |
61 | | -List every publication available to the authenticated account: |
62 | | - |
63 | | -```bash |
64 | | -substack publications list |
65 | | -``` |
66 | | - |
67 | | -Select one for a single command: |
68 | | - |
69 | | -```bash |
70 | | -substack --publication-url https://example.substack.com drafts list |
71 | | -``` |
72 | | - |
73 | | -## Schedule an existing draft |
74 | | - |
75 | | -Pass an ISO 8601 timestamp with a timezone offset or `Z`: |
76 | | - |
77 | | -```bash |
78 | | -substack drafts schedule 12345 --at 2030-01-02T09:00:00+01:00 |
79 | | -``` |
80 | | - |
81 | | -Remove the schedule without deleting the draft: |
82 | | - |
83 | | -```bash |
84 | | -substack drafts unschedule 12345 |
85 | | -``` |
86 | | - |
87 | | -## Stable JSON for automation |
88 | | - |
89 | | -```bash |
90 | | -substack --json drafts list --limit 10 |
91 | | -substack --json drafts export 12345 |
92 | | -``` |
93 | | - |
94 | | -The command writes a JSON object containing `drafts`, `count`, `filter`, |
95 | | -`offset`, and `limit`. Errors are also JSON when `--json` is present. |
96 | | -Export JSON contains `action`, `draft_id`, `markdown`, and |
97 | | -`unsupported_nodes`. |
98 | | - |
99 | | -## Publish and delete |
100 | | - |
101 | | -```bash |
102 | | -substack drafts publish 12345 --no-send |
103 | | -substack drafts delete 12345 --yes |
104 | | -``` |
105 | | - |
106 | | -Publishing and deletion require confirmation. JSON and noninteractive |
107 | | -workflows must pass `--yes`. Publishing runs Substack's prepublish check first. |
108 | | -See [safety and publishing behavior](safety.md). |
109 | | - |
110 | | -The original console scripts remain supported. See |
111 | | -[legacy CLI commands](legacy-cli.md). |
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Unified CLI |
| 4 | +--- |
| 5 | + |
| 6 | +# Unified CLI |
| 7 | + |
| 8 | +Global options such as `--json`, `--cookies`, and `--publication-url` must |
| 9 | +appear before the command. |
| 10 | + |
| 11 | +## Create an unpublished draft |
| 12 | + |
| 13 | +```bash |
| 14 | +substack drafts create post.md |
| 15 | +``` |
| 16 | + |
| 17 | +The title comes from the first Markdown heading, then the filename if the file |
| 18 | +has no heading. Use `--title` to override it. |
| 19 | + |
| 20 | +## Export a draft to Markdown |
| 21 | + |
| 22 | +Print a read-only Markdown backup to standard output: |
| 23 | + |
| 24 | +```bash |
| 25 | +substack drafts export 12345 |
| 26 | +``` |
| 27 | + |
| 28 | +Write it to a UTF-8 file: |
| 29 | + |
| 30 | +```bash |
| 31 | +substack drafts export 12345 --output backup.md |
| 32 | +``` |
| 33 | + |
| 34 | +The command refuses to replace an existing file unless `--force` is present. |
| 35 | +It fetches the draft but performs no server writes. Content without a supported |
| 36 | +Markdown representation is emitted as a versioned opaque HTML comment instead |
| 37 | +of being silently discarded. |
| 38 | + |
| 39 | +## Update a draft from Markdown |
| 40 | + |
| 41 | +Preview the generated update without writing to Substack: |
| 42 | + |
| 43 | +```bash |
| 44 | +substack drafts update 12345 revised-post.md --dry-run --yes |
| 45 | +``` |
| 46 | + |
| 47 | +Apply it after review: |
| 48 | + |
| 49 | +```bash |
| 50 | +substack drafts update 12345 revised-post.md --yes |
| 51 | +``` |
| 52 | + |
| 53 | +Updates preserve unsupported editor nodes exported as |
| 54 | +`python-substack-node:v1` markers and editor image attributes preserved in |
| 55 | +`python-substack-image:v2` markers. The command refuses to remove or alter |
| 56 | +those nodes by default. `--allow-unsupported-change` and |
| 57 | +`--allow-image-replacement` are available only with `--yes` for intentional |
| 58 | +modifications or unmatched image replacements. The CLI uses its authenticated |
| 59 | +API client while rendering, so local images can upload even during a dry run. |
| 60 | + |
| 61 | +## Select a publication |
| 62 | + |
| 63 | +List every publication available to the authenticated account: |
| 64 | + |
| 65 | +```bash |
| 66 | +substack publications list |
| 67 | +``` |
| 68 | + |
| 69 | +Select one for a single command: |
| 70 | + |
| 71 | +```bash |
| 72 | +substack --publication-url https://example.substack.com drafts list |
| 73 | +``` |
| 74 | + |
| 75 | +## Schedule an existing draft |
| 76 | + |
| 77 | +Pass an ISO 8601 timestamp with a timezone offset or `Z`: |
| 78 | + |
| 79 | +```bash |
| 80 | +substack drafts schedule 12345 --at 2030-01-02T09:00:00+01:00 |
| 81 | +``` |
| 82 | + |
| 83 | +Remove the schedule without deleting the draft: |
| 84 | + |
| 85 | +```bash |
| 86 | +substack drafts unschedule 12345 |
| 87 | +``` |
| 88 | + |
| 89 | +## Stable JSON for automation |
| 90 | + |
| 91 | +```bash |
| 92 | +substack --json drafts list --limit 10 |
| 93 | +substack --json drafts export 12345 |
| 94 | +``` |
| 95 | + |
| 96 | +The command writes a JSON object containing `drafts`, `count`, `filter`, |
| 97 | +`offset`, and `limit`. Errors are also JSON when `--json` is present. |
| 98 | +Export JSON contains `action`, `draft_id`, `markdown`, and |
| 99 | +`unsupported_nodes`. |
| 100 | + |
| 101 | +## Publish and delete |
| 102 | + |
| 103 | +```bash |
| 104 | +substack drafts publish 12345 --no-send |
| 105 | +substack drafts delete 12345 --yes |
| 106 | +``` |
| 107 | + |
| 108 | +Publishing and deletion require confirmation. JSON and noninteractive |
| 109 | +workflows must pass `--yes`. Publishing runs Substack's prepublish check first. |
| 110 | +See [safety and publishing behavior](safety.md). |
| 111 | + |
| 112 | +The original console scripts remain supported. See |
| 113 | +[legacy CLI commands](legacy-cli.md). |
0 commit comments