create CLI logo
This commit is contained in:
parent
8c725be8a1
commit
d2154c82ab
3 changed files with 108 additions and 12 deletions
|
@ -13,6 +13,8 @@ const { handleCommand: handleAlerts } = require('./handlers/alerts/alerts_handle
|
||||||
const { handleCommand: handleCase } = require('./handlers/case/case_handler');
|
const { handleCommand: handleCase } = require('./handlers/case/case_handler');
|
||||||
const { handleCommand: handleConfig } = require('./handlers/config/config_handler');
|
const { handleCommand: handleConfig } = require('./handlers/config/config_handler');
|
||||||
const { handleCommand: handleStats } = require('./handlers/stats/stats_handler');
|
const { handleCommand: handleStats } = require('./handlers/stats/stats_handler');
|
||||||
|
const { generateGradientLogo } = require('./utils/cli-logo');
|
||||||
|
|
||||||
const readline = require('readline');
|
const readline = require('readline');
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,17 +89,6 @@ try {
|
||||||
|
|
||||||
const FILE_NAME = 'fylgja-cli.js';
|
const FILE_NAME = 'fylgja-cli.js';
|
||||||
|
|
||||||
// ASCII art logo for the CLI
|
|
||||||
const ASCII_LOGO = `
|
|
||||||
░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓██████▓▒░
|
|
||||||
░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░
|
|
||||||
░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░
|
|
||||||
░▒▓██████▓▒░ ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒▒▓███▓▒░ ░▒▓█▓▒░▒▓████████▓▒░
|
|
||||||
░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░
|
|
||||||
░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░
|
|
||||||
░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓████████▓▒░▒▓██████▓▒░ ░▒▓██████▓▒░░▒▓█▓▒░░▒▓█▓▒░
|
|
||||||
`;
|
|
||||||
|
|
||||||
// Command history array
|
// Command history array
|
||||||
let commandHistory = [];
|
let commandHistory = [];
|
||||||
let historyIndex = -1;
|
let historyIndex = -1;
|
||||||
|
@ -679,7 +670,7 @@ CLI Commands:
|
||||||
* Start the CLI application
|
* Start the CLI application
|
||||||
*/
|
*/
|
||||||
function startCLI() {
|
function startCLI() {
|
||||||
console.log(ASCII_LOGO);
|
console.log(generateGradientLogo());
|
||||||
console.log(`Fylgja CLI v${version} - Interactive SIEM Management Tool`);
|
console.log(`Fylgja CLI v${version} - Interactive SIEM Management Tool`);
|
||||||
console.log(`Type 'help' for usage information or 'exit' to quit\n`);
|
console.log(`Type 'help' for usage information or 'exit' to quit\n`);
|
||||||
|
|
||||||
|
|
105
src/utils/cli-logo.js
Normal file
105
src/utils/cli-logo.js
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
/**
|
||||||
|
* cli-logo.js
|
||||||
|
*
|
||||||
|
* Gradient-colored ASCII logo for CLI
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Define the ASCII logo
|
||||||
|
const logoLines = [
|
||||||
|
'░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓██████▓▒░ ',
|
||||||
|
'░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ',
|
||||||
|
'░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ',
|
||||||
|
'░▒▓██████▓▒░ ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒▒▓███▓▒░ ░▒▓█▓▒░▒▓████████▓▒░ ',
|
||||||
|
'░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ',
|
||||||
|
'░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ',
|
||||||
|
'░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓████████▓▒░▒▓██████▓▒░ ░▒▓██████▓▒░░▒▓█▓▒░░▒▓█▓▒░ '
|
||||||
|
];
|
||||||
|
|
||||||
|
// Colors (hex codes without # prefix)
|
||||||
|
const colors = {
|
||||||
|
teal: '7DE2D1',
|
||||||
|
darkTeal: '339989',
|
||||||
|
offWhite: 'FFFAFB',
|
||||||
|
lavender: '8F95D3'
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert hex to RGB
|
||||||
|
function hexToRgb(hex) {
|
||||||
|
const r = parseInt(hex.substring(0, 2), 16);
|
||||||
|
const g = parseInt(hex.substring(2, 4), 16);
|
||||||
|
const b = parseInt(hex.substring(4, 6), 16);
|
||||||
|
return { r, g, b };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Linear interpolation between two colors
|
||||||
|
function interpolateColor(color1, color2, factor) {
|
||||||
|
return {
|
||||||
|
r: Math.round(color1.r + factor * (color2.r - color1.r)),
|
||||||
|
g: Math.round(color1.g + factor * (color2.g - color1.g)),
|
||||||
|
b: Math.round(color1.b + factor * (color2.b - color1.b))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get ANSI true color escape code
|
||||||
|
function getTrueColorCode(r, g, b) {
|
||||||
|
return `\x1b[38;2;${r};${g};${b}m`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get ANSI 256-color escape code (fallback for terminals without true color support)
|
||||||
|
function get256ColorCode(r, g, b) {
|
||||||
|
// Convert RGB to approximate 256-color code
|
||||||
|
const ansi256 = 16 +
|
||||||
|
36 * Math.round(r * 5 / 255) +
|
||||||
|
6 * Math.round(g * 5 / 255) +
|
||||||
|
Math.round(b * 5 / 255);
|
||||||
|
|
||||||
|
return `\x1b[38;5;${ansi256}m`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a 2D gradient (both horizontal and vertical gradients combined)
|
||||||
|
* This creates the most dramatic effect but is more processing-intensive
|
||||||
|
* @returns {string} The gradient-colored logo
|
||||||
|
*/
|
||||||
|
function generateGradientLogo() {
|
||||||
|
// Convert hex colors to RGB (corners of the 2D gradient)
|
||||||
|
const topLeft = hexToRgb(colors.teal);
|
||||||
|
const topRight = hexToRgb(colors.darkTeal);
|
||||||
|
const bottomLeft = hexToRgb(colors.offWhite);
|
||||||
|
const bottomRight = hexToRgb(colors.lavender);
|
||||||
|
|
||||||
|
// Initialize gradient logo
|
||||||
|
let gradientLogo = '\n';
|
||||||
|
|
||||||
|
// Process each line
|
||||||
|
for (let y = 0; y < logoLines.length; y++) {
|
||||||
|
const line = logoLines[y];
|
||||||
|
const verticalPosition = y / (logoLines.length - 1);
|
||||||
|
|
||||||
|
// Interpolate top and bottom colors
|
||||||
|
const leftColor = interpolateColor(topLeft, bottomLeft, verticalPosition);
|
||||||
|
const rightColor = interpolateColor(topRight, bottomRight, verticalPosition);
|
||||||
|
|
||||||
|
// Process each character in the line
|
||||||
|
for (let x = 0; x < line.length; x++) {
|
||||||
|
const char = line[x];
|
||||||
|
const horizontalPosition = x / (line.length - 1);
|
||||||
|
|
||||||
|
// Interpolate between left and right colors
|
||||||
|
const color = interpolateColor(leftColor, rightColor, horizontalPosition);
|
||||||
|
|
||||||
|
// Apply the color and add the character
|
||||||
|
gradientLogo += getTrueColorCode(color.r, color.g, color.b) + char;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset color and add newline
|
||||||
|
gradientLogo += '\x1b[0m\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
return gradientLogo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Export the gradient logo functions
|
||||||
|
module.exports = {
|
||||||
|
generateGradientLogo,
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue