@aaronshaf/confluence-cli 1.0.1 → 1.0.4

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/README.md CHANGED
@@ -47,6 +47,7 @@ cn spaces
47
47
  | `cn comments <id\|file>` | Show page comments |
48
48
  | `cn labels <id\|file>` | Manage page labels |
49
49
  | `cn move <id\|file> <parentId>` | Move a page to a new parent |
50
+ | `cn read <id\|file>` | Read and display page content |
50
51
  | `cn attachments <id\|file>` | Manage page attachments |
51
52
  | `cn folder <subcommand>` | Manage folders (create, list, delete, move) |
52
53
  | `cn clone <SPACE_KEY>` | Clone a space to a new folder |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aaronshaf/confluence-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "Confluence CLI for syncing spaces and local markdown files",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,53 @@
1
+ import chalk from 'chalk';
2
+ import { ConfluenceClient } from '../../lib/confluence-client/index.js';
3
+ import { ConfigManager } from '../../lib/config.js';
4
+ import { EXIT_CODES } from '../../lib/errors.js';
5
+ import { escapeXml } from '../../lib/formatters.js';
6
+ import { MarkdownConverter } from '../../lib/markdown/index.js';
7
+ import { resolvePageTarget } from '../../lib/resolve-page-target.js';
8
+
9
+ export interface ReadCommandOptions {
10
+ xml?: boolean;
11
+ html?: boolean;
12
+ }
13
+
14
+ export async function readCommand(target: string, options: ReadCommandOptions = {}): Promise<void> {
15
+ const configManager = new ConfigManager();
16
+ const config = await configManager.getConfig();
17
+
18
+ if (!config) {
19
+ console.error(chalk.red('Not configured. Run: cn setup'));
20
+ process.exit(EXIT_CODES.CONFIG_ERROR);
21
+ }
22
+
23
+ if (options.xml && options.html) {
24
+ console.error(chalk.red('Cannot use --xml and --html together.'));
25
+ process.exit(EXIT_CODES.INVALID_ARGUMENTS);
26
+ }
27
+
28
+ const pageId = resolvePageTarget(target);
29
+ const client = new ConfluenceClient(config);
30
+ const page = await client.getPage(pageId, true);
31
+
32
+ const storageHtml = page.body?.storage?.value || '';
33
+
34
+ if (options.xml) {
35
+ const converter = new MarkdownConverter();
36
+ const markdown = converter.convert(storageHtml);
37
+ console.log('<page>');
38
+ console.log(` <id>${escapeXml(page.id)}</id>`);
39
+ console.log(` <title>${escapeXml(page.title)}</title>`);
40
+ console.log(` <content>${escapeXml(markdown)}</content>`);
41
+ console.log('</page>');
42
+ return;
43
+ }
44
+
45
+ if (options.html) {
46
+ console.log(storageHtml);
47
+ return;
48
+ }
49
+
50
+ const converter = new MarkdownConverter();
51
+ const markdown = converter.convert(storageHtml);
52
+ console.log(markdown);
53
+ }
package/src/cli/help.ts CHANGED
@@ -171,8 +171,16 @@ ${chalk.yellow('Usage:')}
171
171
  cn spaces [options]
172
172
 
173
173
  ${chalk.yellow('Options:')}
174
+ --limit <n> Number of spaces per page (default: 25)
175
+ --page <n> Page number for pagination
174
176
  --xml Output in XML format
175
177
  --help Show this help message
178
+
179
+ ${chalk.yellow('Examples:')}
180
+ cn spaces List first 25 spaces
181
+ cn spaces --limit 50 List 50 spaces
182
+ cn spaces --page 2 Show second page of results
183
+ cn spaces --page 2 --limit 10 Custom page size
176
184
  `);
177
185
  }
178
186
 
@@ -214,6 +222,29 @@ ${chalk.yellow('Options:')}
214
222
  `);
215
223
  }
216
224
 
225
+ export function showReadHelp(): void {
226
+ console.log(`
227
+ ${chalk.bold('cn read - Read and display page content')}
228
+
229
+ ${chalk.yellow('Usage:')}
230
+ cn read <id|file> [options]
231
+
232
+ ${chalk.yellow('Arguments:')}
233
+ id|file Page ID or path to local .md file
234
+
235
+ ${chalk.yellow('Options:')}
236
+ --xml Output in XML format
237
+ --html Output raw Confluence storage format HTML
238
+ --help Show this help message
239
+
240
+ ${chalk.yellow('Examples:')}
241
+ cn read 123456 Read page by ID
242
+ cn read ./docs/page.md Read page from local file
243
+ cn read 123456 --xml Read page in XML format
244
+ cn read 123456 --html Read raw HTML storage format
245
+ `);
246
+ }
247
+
217
248
  export function showCreateHelp(): void {
218
249
  console.log(`
219
250
  ${chalk.bold('cn create - Create a new Confluence page')}
@@ -419,6 +450,7 @@ ${chalk.yellow('Commands:')}
419
450
  cn search Search pages using CQL
420
451
  cn spaces List available spaces
421
452
  cn info Show page info and labels
453
+ cn read Read and display page content
422
454
  cn create Create a new page
423
455
  cn update Update an existing page
424
456
  cn delete Delete a page
package/src/cli/index.ts CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  showDoctorHelp,
14
14
  showHelp,
15
15
  showInfoHelp,
16
+ showReadHelp,
16
17
  showLabelsHelp,
17
18
  showMoveHelp,
18
19
  showOpenHelp,
@@ -37,6 +38,7 @@ import { moveCommand } from './commands/move.js';
37
38
  import { openCommand } from './commands/open.js';
38
39
  import { folderCommand } from './commands/folder.js';
39
40
  import { pullCommand } from './commands/pull.js';
41
+ import { readCommand } from './commands/read.js';
40
42
  import { searchCommand } from './commands/search.js';
41
43
  import { setup } from './commands/setup.js';
42
44
  import { spacesCommand } from './commands/spaces.js';
@@ -276,6 +278,21 @@ async function main(): Promise<void> {
276
278
  break;
277
279
  }
278
280
 
281
+ case 'read': {
282
+ if (args.includes('--help')) {
283
+ showReadHelp();
284
+ process.exit(EXIT_CODES.SUCCESS);
285
+ }
286
+ const target = subArgs.find((arg) => !arg.startsWith('--'));
287
+ if (!target) {
288
+ console.error(chalk.red('Page ID or file path is required.'));
289
+ console.log(chalk.gray('Usage: cn read <id|file>'));
290
+ process.exit(EXIT_CODES.INVALID_ARGUMENTS);
291
+ }
292
+ await readCommand(target, { xml: args.includes('--xml'), html: args.includes('--html') });
293
+ break;
294
+ }
295
+
279
296
  case 'create': {
280
297
  if (args.includes('--help')) {
281
298
  showCreateHelp();