digital-matrix-rain
Version:
A cool matrix-style digital rain animation for terminal/console applications
70 lines (58 loc) • 1.56 kB
JavaScript
/**
* CLI for Matrix Animation Package
*/
const { MatrixRain } = require('./index.js');
// Parse command line arguments
const args = process.argv.slice(2);
const options = {};
// Default values
options.speed = 100;
options.color = 'green';
options.density = 0.1;
// Parse arguments
for (let i = 0; i < args.length; i++) {
switch (args[i]) {
case '--speed':
case '-s':
options.speed = parseInt(args[i + 1]) || 100;
i++;
break;
case '--color':
case '-c':
options.color = args[i + 1] || 'green';
i++;
break;
case '--density':
case '-d':
options.density = parseFloat(args[i + 1]) || 0.1;
i++;
break;
case '--help':
case '-h':
console.log(`
Matrix Animation CLI
Usage: digital-matrix [options]
Options:
-s, --speed <number> Animation speed in ms (default: 100)
-c, --color <color> Color (green, red, blue, yellow, magenta, cyan, white)
-d, --density <number> Drop density 0.0-1.0 (default: 0.1)
-h, --help Show help
Examples:
digital-matrix
digital-matrix --speed 50 --color cyan
digital-matrix -s 150 -c red -d 0.2
Press Ctrl+C to stop the animation.
`);
process.exit(0);
break;
}
}
// Welcome message
console.log('🌊 Matrix Digital Rain Animation');
console.log('Press Ctrl+C to stop\n');
// Start animation after brief delay
setTimeout(() => {
const matrix = new MatrixRain(options);
matrix.start();
}, 1500);