tuiHoneyPot

front and back end of my TUI honeypot
Log | Files | Refs | README

clear.js (1116B)


      1 /**
      2  * The "clear" command
      3  * @param  {window.FakeTerminal} instance The instance of FakeTerminal
      4  * @return {Object}
      5  */
      6 window.FakeTerminal.command.clear = function (instance) {
      7 
      8     //  Extend the base command
      9     window.FakeTerminal.command.apply(this, arguments);
     10 
     11     /**
     12      * Avoid scope issues by using `base` instead of `this`
     13      * @type {Object}
     14      */
     15     const base = this;
     16 
     17     // --------------------------------------------------------------------------
     18 
     19     /**
     20      * Describes the command
     21      * @return {Object}
     22      */
     23     base.info = function () {
     24         return {
     25             description: 'Clears the screen'
     26         };
     27     };
     28 
     29     // --------------------------------------------------------------------------
     30 
     31     /**
     32      * Executes the command
     33      * @return {Object} A promise which will be resolved when the command completes
     34      */
     35     base.execute = function () {
     36         instance.output.clear();
     37         base.deferred.resolve();
     38         return base.deferred.promise();
     39     };
     40 
     41     // --------------------------------------------------------------------------
     42 
     43     return base;
     44 };