UNPKG

mbo-test-cli

Version:
127 lines (100 loc) 2.79 kB
#!/usr/bin/env node var blessed = require('blessed'), contrib = require('blessed-contrib'), spinner = require('simple-spinner'), request = require('request'), argv = require('minimist')(process.argv.slice(2)); spinner.change_sequence([ "◓", "◑", "◒", "◐" ]); var screen = blessed.screen({ autoPadding: true, smartCSR: true, title: 'Logsene command-line interface' }); var grid = new contrib.grid({rows: 12, cols: 12, screen: screen}) var log = grid.set(8, 6, 4, 2, contrib.log, {fg: 'green', selectedFg: 'green', label: 'logsene log'}); //var res = request.get("http://") spinner.start(50) setTimeout(function() { spinner.stop(); printArt(); }, 2000); var art = [ " _ _", " (c).-.(c) __", " / ._. \\ / /| ____ ____ ____ ___ ____ ___ ", " __\\( Y )/__ / / // __ \\/ __ `/ ___/ _ \\/ __ \\/ _ \\", "(_.-/'-'\\-._)/ /_// /_/ / /_/ (__ ) __/ / / / __/\\", " || S || /_____|____/\\__, /____/\\___/_/ /_/\\___/\\/", " _.' `-' '._\\______\\___\\/____/\\___\\/\\__\\_\\/\\_\\/\\__\\/", "(.-./`-'\\.-.) \\___\\/", " `-' `-'"]; var printArt = function() { for (var line in art) { if (art.hasOwnProperty(line)) { console.log(art[line]); screen.render(); } } }; var line = contrib.line( { style: { line: "yellow", text: "green", baseline: "black"}, xLabelPadding: 3, xPadding: 5, label: 'Title'}), data = { x: ['t1', 't2', 't3', 't4'], y: [5, 1, 7, 5] }; screen.append(line) //must append before setting data line.setData([data]) var map = contrib.map({label: 'Requests worldwide'}); screen.append(map); map.addMarker({"lon" : "-79.0000", "lat" : "37.5000", color: "red", char: "X" }) screen.key(['escape', 'q', 'C-c'], function(ch, key) { return process.exit(0); }) /* // Append our box to the screen. screen.append(box); // Add a PNG icon to the box (X11 only) var icon = blessed.image({ parent: box, top: 0, left: 0, width: 'shrink', height: 'shrink', file: __dirname + '/my-program-icon.png', search: false }); // If our box is clicked, change the content. box.on('click', function(data) { box.setContent('{center}Some different {red-fg}content{/red-fg}.{/center}'); screen.render(); }); // If box is focused, handle `enter`/`return` and give us some more content. box.key('enter', function(ch, key) { box.setContent('{right}Even different {black-fg}content{/black-fg}.{/right}\n'); box.setLine(1, 'bar'); box.insertLine(1, 'foo'); screen.render(); }); // Quit on Escape, q, or Control-C. screen.key(['escape', 'q', 'C-c'], function(ch, key) { return process.exit(0); }); // Focus our element. box.focus(); */ // Render the screen. //screen.render();