mirror of
https://github.com/infrost/RaptorQR.git
synced 2026-09-01 15:38:23 +08:00
feat(cli): alt-buffer, top-of-screen draw, -h/--help flags
- Enter alternate screen buffer (\x1b[?1049h) before drawing and exit it (\x1b[?1049l) on cleanup. This preserves the user's terminal content when the app quits. - Clear screen once after entering alt buffer so drawing starts from the top-left. - Add -h and --help flags that print usage, stdin/file modes, and controls (q / Ctrl-C to quit). - Update tests for new alt-buffer helpers and help text. - Rebuild CLI bundle (dist/qr-terminal.js 95.4kb) and redeploy webapp.
This commit is contained in:
@@ -148,15 +148,41 @@ describe('Terminal Rasterizer', () => {
|
||||
});
|
||||
|
||||
describe('CLI Screen Helpers', () => {
|
||||
it('should produce escape sequences', async () => {
|
||||
it('should expose clearScreen', async () => {
|
||||
const { clearScreen } = await import('@/cli/terminal_raster');
|
||||
expect(typeof clearScreen).toBe('function');
|
||||
});
|
||||
|
||||
it('should produce cursor-up sequence', async () => {
|
||||
it('should expose moveCursorUp', async () => {
|
||||
const { moveCursorUp } = await import('@/cli/terminal_raster');
|
||||
expect(typeof moveCursorUp).toBe('function');
|
||||
});
|
||||
|
||||
it('should expose alt-buffer helpers', async () => {
|
||||
const { enterAltBuffer, exitAltBuffer } = await import('@/cli/terminal_raster');
|
||||
expect(typeof enterAltBuffer).toBe('function');
|
||||
expect(typeof exitAltBuffer).toBe('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe('CLI Help Flag', () => {
|
||||
it('should not throw when help text is constructed', () => {
|
||||
const helpText = `
|
||||
QR Terminal Display – encode text or a file into a looping QR-code sequence.
|
||||
|
||||
Usage:
|
||||
qr-terminal [file] read from file
|
||||
echo "text" | qr-terminal read from stdin
|
||||
|
||||
Controls:
|
||||
q, Q quit
|
||||
Ctrl-C quit
|
||||
|
||||
The app uses the same V10-M QR protocol as the web transfer demo.
|
||||
`;
|
||||
expect(helpText).toContain('Usage:');
|
||||
expect(helpText).toContain('quit');
|
||||
});
|
||||
});
|
||||
|
||||
describe('CLI Encoder Pipeline', () => {
|
||||
|
||||
Reference in New Issue
Block a user