@heyhuynhgiabuu/pi-pretty 0.1.2 → 0.1.3
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/package.json +1 -1
- package/src/index.ts +23 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyhuynhgiabuu/pi-pretty",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Pretty terminal output for pi — syntax-highlighted file reads, colored bash output, tree-view directory listings, and more.",
|
|
5
5
|
"author": "huynhgiabuu",
|
|
6
6
|
"license": "MIT",
|
package/src/index.ts
CHANGED
|
@@ -639,10 +639,29 @@ export default function piPrettyExtension(pi: any): void {
|
|
|
639
639
|
|
|
640
640
|
const d = result.details;
|
|
641
641
|
if (d?._type === "bashResult") {
|
|
642
|
-
const { summary } = renderBashOutput(d.text, d.exitCode);
|
|
643
|
-
const lines = d.text.split("\n")
|
|
644
|
-
const
|
|
645
|
-
|
|
642
|
+
const { summary, body } = renderBashOutput(d.text, d.exitCode);
|
|
643
|
+
const lines = d.text.split("\n");
|
|
644
|
+
const lineCount = lines.length;
|
|
645
|
+
const lineInfo = lineCount > 1 ? ` ${FG_DIM}(${lineCount} lines)${RST}` : "";
|
|
646
|
+
const header = ` ${summary}${lineInfo}`;
|
|
647
|
+
|
|
648
|
+
// Show output content
|
|
649
|
+
if (d.text.trim()) {
|
|
650
|
+
const maxShow = ctx.expanded ? lineCount : MAX_PREVIEW_LINES;
|
|
651
|
+
const show = lines.slice(0, maxShow);
|
|
652
|
+
const tw = termW();
|
|
653
|
+
const out: string[] = [header, rule(tw)];
|
|
654
|
+
for (const line of show) {
|
|
655
|
+
out.push(` ${line}`);
|
|
656
|
+
}
|
|
657
|
+
out.push(rule(tw));
|
|
658
|
+
if (lineCount > maxShow) {
|
|
659
|
+
out.push(`${FG_DIM} … ${lineCount - maxShow} more lines${RST}`);
|
|
660
|
+
}
|
|
661
|
+
text.setText(out.join("\n"));
|
|
662
|
+
} else {
|
|
663
|
+
text.setText(header);
|
|
664
|
+
}
|
|
646
665
|
return text;
|
|
647
666
|
}
|
|
648
667
|
|