vtac-terminal 1.0.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/index.ts ADDED
@@ -0,0 +1,73 @@
1
+ #! /usr/bin/env node
2
+
3
+ import figlet from 'figlet'
4
+ import { Command } from 'commander'
5
+ import { readFileSync } from 'fs'
6
+ import { VTAC } from './VTAC/VTAC'
7
+
8
+ const VERSION = '1.0.0'
9
+
10
+ const vtac = new VTAC()
11
+
12
+ const program = new Command()
13
+ program.showHelpAfterError()
14
+ program
15
+ .name('vtac')
16
+ .description('A fantasy ASCII terminal emulator.')
17
+ .version(VERSION, '-v, --version', 'Output the current version')
18
+ .helpOption('-h, --help', 'Output help / options')
19
+ .option('-p, --path <path>', 'Path to the serial port (e.g., /dev/ttyUSB0)')
20
+ .option('-b, --baudrate <baudrate>', 'Baud Rate', '9600')
21
+ .option('-a, --parity <parity>', 'Parity (odd | even | none)', 'none')
22
+ .option('-d, --databits <databits>', 'Data Bits (5 | 6 | 7 | 8)', '8')
23
+ .option('-t, --stopbits <stopbits>', 'Stop Bits (1 | 1.5 | 2)', '1')
24
+ .option('-f, --fullscreen', 'Enable fullscreen mode', false)
25
+ .option('-s, --scale <scale>', 'Scale', '2')
26
+ .option('-l, --load <load>', 'Path to data file to load (e.g. /path/to/data.bin)')
27
+ .addHelpText('beforeAll', figlet.textSync('VT-AC', { font: 'cricket' }) + '\n' + `Version: ${VERSION} | A.C. Wright Design\n`)
28
+ .parse(process.argv)
29
+
30
+ const options = program.opts()
31
+ if (options.path) {
32
+ vtac.path = options.path
33
+ }
34
+ if (options.baudrate) {
35
+ vtac.baudRate = parseInt(options.baudrate)
36
+ }
37
+ if (options.parity) {
38
+ vtac.parity = options.parity
39
+ }
40
+ if (options.databits) {
41
+ const dataBits = parseInt(options.databits)
42
+ if (dataBits == 5 || dataBits == 6 || dataBits == 7 || dataBits == 8) {
43
+ vtac.dataBits = dataBits
44
+ } else {
45
+ console.log('Error: Invalid Data Bits')
46
+ }
47
+ }
48
+ if (options.stopbits) {
49
+ const stopBits = parseInt(options.stopbits)
50
+ if (stopBits == 1 || stopBits == 1.5 || stopBits == 2) {
51
+ vtac.stopBits = stopBits
52
+ } else {
53
+ console.log('Error: Invalid Stop Bits')
54
+ }
55
+ }
56
+ if (options.fullscreen) {
57
+ vtac.fullscreen = options.fullscreen
58
+ }
59
+ if (options.scale) {
60
+ vtac.scale = parseInt(options.scale)
61
+ }
62
+ if (options.load) {
63
+ try {
64
+ const data = readFileSync(options.load)
65
+ for (let i = 0; i < data.length; i++) {
66
+ vtac.parse(data[i])
67
+ }
68
+ } catch (err) {
69
+ console.log('Error loading file:', err)
70
+ }
71
+ }
72
+
73
+ vtac.launch()
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "src",
4
+ "outDir": "dist",
5
+ "strict": true,
6
+ "target": "es6",
7
+ "module": "commonjs",
8
+ "sourceMap": true,
9
+ "esModuleInterop": true,
10
+ "moduleResolution": "node"
11
+ }
12
+ }