@readwise/cli 0.3.1 → 0.5.0
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 +3 -0
- package/dist/config.d.ts +1 -0
- package/dist/index.js +9 -3
- package/dist/tui/app.js +875 -232
- package/dist/tui/term.js +45 -6
- package/package.json +3 -3
- package/src/config.ts +1 -0
- package/src/index.ts +10 -3
- package/src/tui/app.ts +849 -224
- package/src/tui/term.ts +41 -6
package/README.md
CHANGED
|
@@ -64,6 +64,8 @@ readwise reader-get-document-details --document-id <document-id>
|
|
|
64
64
|
readwise reader-get-document-highlights --document-id <document-id>
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
+
> **Tip: seen vs unseen documents.** In the response, `firstOpenedAt: null` means the document is **unseen** (never opened). A non-null `firstOpenedAt` means it has been opened/seen. Use `reader-edit-document-metadata --seen true` to mark a document as seen.
|
|
68
|
+
|
|
67
69
|
### Save a document
|
|
68
70
|
|
|
69
71
|
```bash
|
|
@@ -88,6 +90,7 @@ readwise reader-move-document --document-id <id> --location archive
|
|
|
88
90
|
|
|
89
91
|
# Edit metadata
|
|
90
92
|
readwise reader-edit-document-metadata --document-id <id> --title "Better Title"
|
|
93
|
+
readwise reader-edit-document-metadata --document-id <id> --seen true # mark as seen/opened
|
|
91
94
|
readwise reader-set-document-notes --document-id <id> --notes "Updated notes"
|
|
92
95
|
```
|
|
93
96
|
|
package/dist/config.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -90,8 +90,9 @@ async function main() {
|
|
|
90
90
|
const forceRefresh = process.argv.includes("--refresh");
|
|
91
91
|
const positionalArgs = process.argv.slice(2).filter((a) => !a.startsWith("--"));
|
|
92
92
|
const hasSubcommand = positionalArgs.length > 0;
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
const wantsHelp = process.argv.includes("--help") || process.argv.includes("-h");
|
|
94
|
+
// If no subcommand, TTY, and authenticated → launch TUI (unless --help)
|
|
95
|
+
if (!hasSubcommand && !wantsHelp && process.stdout.isTTY && config.access_token) {
|
|
95
96
|
try {
|
|
96
97
|
const { token, authType } = await ensureValidToken();
|
|
97
98
|
const tools = await getTools(token, authType, forceRefresh);
|
|
@@ -110,6 +111,12 @@ async function main() {
|
|
|
110
111
|
console.log("\nRun `readwise login` or `readwise login-with-token` to authenticate.");
|
|
111
112
|
return;
|
|
112
113
|
}
|
|
114
|
+
// If not authenticated and trying a non-login command, tell user to log in
|
|
115
|
+
if (!config.access_token && hasSubcommand && positionalArgs[0] !== "login" && positionalArgs[0] !== "login-with-token") {
|
|
116
|
+
process.stderr.write("\x1b[31mNot logged in.\x1b[0m Run `readwise login` or `readwise login-with-token` to authenticate.\n");
|
|
117
|
+
process.exitCode = 1;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
113
120
|
// Try to load tools if we have a token (for subcommand mode)
|
|
114
121
|
if (config.access_token) {
|
|
115
122
|
try {
|
|
@@ -119,7 +126,6 @@ async function main() {
|
|
|
119
126
|
}
|
|
120
127
|
catch (err) {
|
|
121
128
|
// Don't fail — login command should still work
|
|
122
|
-
// Only warn if user is trying to run a non-login command
|
|
123
129
|
if (hasSubcommand && positionalArgs[0] !== "login" && positionalArgs[0] !== "login-with-token") {
|
|
124
130
|
process.stderr.write(`\x1b[33mWarning: Could not fetch tools: ${err.message}\x1b[0m\n`);
|
|
125
131
|
}
|