Update package dependencies to include 'ink' and 'ink-text-input' for enhanced terminal UI capabilities. Add new script 'start:ink' for launching the ink-based CLI interface. Clean up example.js by removing unnecessary whitespace for improved readability.
This commit is contained in:
23
cli-ink.js
Normal file
23
cli-ink.js
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env node
|
||||
import 'dotenv/config';
|
||||
import React from 'react';
|
||||
import { render } from 'ink';
|
||||
import InkApp from './src/ui/InkApp.js';
|
||||
|
||||
const { unmount } = render(React.createElement(InkApp));
|
||||
|
||||
// ESC to exit
|
||||
if (process.stdin.isTTY) {
|
||||
try { process.stdin.setRawMode(true); } catch { }
|
||||
const onData = (data) => {
|
||||
const str = typeof data === 'string' ? data : String(data);
|
||||
if (str === '\u001b' || (str.length && str.charCodeAt(0) === 27)) {
|
||||
unmount();
|
||||
try { process.stdin.setRawMode(false); } catch { }
|
||||
process.exit(0);
|
||||
}
|
||||
};
|
||||
process.stdin.on('data', onData);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user