@octen.ai/cli 0.1.1 → 0.1.2
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/commands/fetch.js
CHANGED
|
@@ -16,11 +16,12 @@ export function registerFetch(program) {
|
|
|
16
16
|
.option("--videos", "include videos")
|
|
17
17
|
.option("--audio", "include audio")
|
|
18
18
|
.option("--favicon", "include favicon")
|
|
19
|
+
.option("--full", "print full page content untruncated (pretty mode)")
|
|
19
20
|
.action(async (urls, opts, command) => {
|
|
20
21
|
const g = command.optsWithGlobals();
|
|
21
22
|
const client = makeClient(g);
|
|
22
23
|
const req = buildExtractRequest(urls, opts);
|
|
23
24
|
const res = await client.request(ENDPOINTS.extract, req);
|
|
24
|
-
emit(res, chooseMode(g, process.stdout.isTTY ?? false), renderExtract);
|
|
25
|
+
emit(res, chooseMode(g, process.stdout.isTTY ?? false), (d) => renderExtract(d, opts.full));
|
|
25
26
|
});
|
|
26
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function renderExtract(data: any): string;
|
|
1
|
+
export declare function renderExtract(data: any, full?: boolean): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import pc from "picocolors";
|
|
2
2
|
const MAX_CONTENT = 500;
|
|
3
|
-
export function renderExtract(data) {
|
|
3
|
+
export function renderExtract(data, full = false) {
|
|
4
4
|
// The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
|
|
5
5
|
// Unwrap to the inner body only when `data.data` is a non-array object (the real
|
|
6
6
|
// API shape); fall back to the raw object otherwise so un-enveloped inputs still work.
|
|
@@ -45,7 +45,7 @@ export function renderExtract(data) {
|
|
|
45
45
|
}
|
|
46
46
|
else if (item.full_content) {
|
|
47
47
|
const raw = item.full_content;
|
|
48
|
-
const snippet = raw.length > MAX_CONTENT ? raw.slice(0, MAX_CONTENT) + "…" : raw;
|
|
48
|
+
const snippet = !full && raw.length > MAX_CONTENT ? raw.slice(0, MAX_CONTENT) + "…" : raw;
|
|
49
49
|
lines.push(` ${snippet}`);
|
|
50
50
|
}
|
|
51
51
|
}
|