@robin7331/papyrus-cli 0.1.4 → 0.1.5

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
@@ -24,6 +24,9 @@ papyrus --help
24
24
  ## Usage
25
25
 
26
26
  ```bash
27
+ # Show installed CLI version
28
+ papyrus --version
29
+
27
30
  # Single file (auto mode; if no API key is found, Papyrus prompts you to paste one)
28
31
  papyrus ./path/to/input.pdf
29
32
 
@@ -95,6 +98,16 @@ Example:
95
98
  papyrus ./docs/invoice.pdf
96
99
  ```
97
100
 
101
+ ### `-v, --version`
102
+
103
+ Print the installed Papyrus CLI version.
104
+
105
+ Example:
106
+
107
+ ```bash
108
+ papyrus --version
109
+ ```
110
+
98
111
  ### `--format <format>`
99
112
 
100
113
  Output format override:
package/dist/cli.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "dotenv/config";
3
+ import { readFileSync } from "node:fs";
3
4
  import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
4
5
  import { dirname, join, relative, resolve } from "node:path";
5
6
  import { Command } from "commander";
@@ -9,8 +10,10 @@ import { defaultOutputPath, formatDurationMs, isPdfPath, looksLikeFileOutput, pa
9
10
  const program = new Command();
10
11
  const configFilePath = getConfigFilePath();
11
12
  const OPENAI_API_KEYS_URL = "https://platform.openai.com/settings/organization/api-keys";
13
+ const cliVersion = getCliVersion();
12
14
  program
13
15
  .name("papyrus")
16
+ .version(cliVersion, "-v, --version", "display version number")
14
17
  .description("Convert PDF files to Markdown or text using the OpenAI Agents SDK")
15
18
  .argument("<input>", "Path to input PDF file or folder")
16
19
  .option("-o, --output <path>", "Path to output file (single input) or output directory (folder input)")
@@ -547,3 +550,17 @@ function mergeUsage(target, delta) {
547
550
  function printUsageTotals(usage) {
548
551
  console.log(`Token usage: input=${usage.inputTokens}, output=${usage.outputTokens}, total=${usage.totalTokens}, requests=${usage.requests}`);
549
552
  }
553
+ function getCliVersion() {
554
+ try {
555
+ const packageJsonPath = new URL("../package.json", import.meta.url);
556
+ const raw = readFileSync(packageJsonPath, "utf8");
557
+ const parsed = JSON.parse(raw);
558
+ if (typeof parsed.version === "string" && parsed.version.trim().length > 0) {
559
+ return parsed.version;
560
+ }
561
+ }
562
+ catch {
563
+ // ignore and use fallback
564
+ }
565
+ return "0.0.0";
566
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robin7331/papyrus-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "description": "Convert PDF to markdown or text with the OpenAI Agents SDK",
6
6
  "repository": {
package/src/cli.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import "dotenv/config";
4
+ import { readFileSync } from "node:fs";
4
5
  import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
5
6
  import { dirname, join, relative, resolve } from "node:path";
6
7
  import { Command } from "commander";
@@ -32,6 +33,7 @@ import {
32
33
  const program = new Command();
33
34
  const configFilePath = getConfigFilePath();
34
35
  const OPENAI_API_KEYS_URL = "https://platform.openai.com/settings/organization/api-keys";
36
+ const cliVersion = getCliVersion();
35
37
 
36
38
  type ConfigInitOptions = {
37
39
  force?: boolean;
@@ -39,6 +41,7 @@ type ConfigInitOptions = {
39
41
 
40
42
  program
41
43
  .name("papyrus")
44
+ .version(cliVersion, "-v, --version", "display version number")
42
45
  .description("Convert PDF files to Markdown or text using the OpenAI Agents SDK")
43
46
  .argument("<input>", "Path to input PDF file or folder")
44
47
  .option("-o, --output <path>", "Path to output file (single input) or output directory (folder input)")
@@ -733,3 +736,18 @@ function printUsageTotals(usage: ConvertUsage): void {
733
736
  `Token usage: input=${usage.inputTokens}, output=${usage.outputTokens}, total=${usage.totalTokens}, requests=${usage.requests}`
734
737
  );
735
738
  }
739
+
740
+ function getCliVersion(): string {
741
+ try {
742
+ const packageJsonPath = new URL("../package.json", import.meta.url);
743
+ const raw = readFileSync(packageJsonPath, "utf8");
744
+ const parsed = JSON.parse(raw) as { version?: unknown };
745
+ if (typeof parsed.version === "string" && parsed.version.trim().length > 0) {
746
+ return parsed.version;
747
+ }
748
+ } catch {
749
+ // ignore and use fallback
750
+ }
751
+
752
+ return "0.0.0";
753
+ }