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:
Hermes Agent
2026-05-03 22:14:50 +00:00
parent c0baff8d42
commit 352fc2d459
3 changed files with 85 additions and 6 deletions
+28 -2
View File
@@ -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', () => {