pyre-cli 3.4.0 → 3.6.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/src/ux.ts ADDED
@@ -0,0 +1,62 @@
1
+ export function truncate(str: string, maxLen: number): string {
2
+ if (str.length <= maxLen) return str;
3
+ return str.substring(0, maxLen - 3) + '...';
4
+ }
5
+
6
+ export function renderHeader(screenName: string): void {
7
+ const width = Math.min(process.stdout.columns || 80, 80);
8
+ const title = ` PYRE CLI - [${screenName}] `;
9
+ const border = '='.repeat(width);
10
+ console.log(border);
11
+ console.log(title.padStart((width + title.length) / 2).padEnd(width));
12
+ console.log(border + '\n');
13
+ }
14
+
15
+ export function renderCustomizationMenu(selectedIndex: number): void {
16
+ const options = [
17
+ 'Theme Mode: Dark / Light',
18
+ 'Log Level: Verbose / Info / Error',
19
+ 'Update Interval: 1000ms',
20
+ 'Enable Telemetry: False',
21
+ 'Back to Main Menu'
22
+ ];
23
+
24
+ console.log(' Customization Options:');
25
+ console.log(' ------------------------------------------');
26
+
27
+ options.forEach((opt, idx) => {
28
+ const isSelected = idx === (selectedIndex % options.length);
29
+ const prefix = isSelected ? '> ' : ' ';
30
+ const formattedOption = truncate(opt, 60);
31
+ if (isSelected) {
32
+ console.log(`\x1b[36m${prefix}${formattedOption}\x1b[0m`);
33
+ } else {
34
+ console.log(`${prefix}${formattedOption}`);
35
+ }
36
+ });
37
+
38
+ console.log(' ------------------------------------------');
39
+ console.log(' Use Up/Down arrows to navigate. Press ESC or Q to return.');
40
+ }
41
+
42
+ export function renderActivityMonitor(processes: any[]): void {
43
+ console.log(' Active Processes Monitor:');
44
+ console.log(' --------------------------------------------------');
45
+ console.log(' PID | COMMAND | CPU % | MEM % ');
46
+ console.log(' --------------------------------------------------');
47
+
48
+ if (!processes || processes.length === 0) {
49
+ console.log(' No process data available or scanning processes...');
50
+ } else {
51
+ processes.slice(0, 15).forEach((proc) => {
52
+ const pid = String(proc.pid).padEnd(7);
53
+ const name = truncate(proc.name || 'unknown', 20).padEnd(20);
54
+ const cpu = String(proc.cpu || '0.0').padEnd(7);
55
+ const mem = String(proc.mem || '0.0').padEnd(7);
56
+ console.log(` ${pid} | ${name} | ${cpu} | ${mem}`);
57
+ });
58
+ }
59
+
60
+ console.log(' --------------------------------------------------');
61
+ console.log(' Press [Q] or [ESC] to return to Main Menu.');
62
+ }