File: commands/webfan/ftp.js

Recommend this page to a friend!
  Classes of Melanie Wehowski   Widget CLI   commands/webfan/ftp.js   Download  
File: commands/webfan/ftp.js
Role: Example script
Content type: text/plain
Description: Example script
Class: Widget CLI
Process commands entered by the user
Author: By
Last change:
Date: 7 years ago
Size: 3,247 bytes
 

Contents

Class file image Download
/* webfan (C) Till Wehowski, Webfan.de - All rights reserved. */ 'use strict'; var frdl = require('frdl'); var util = require('util'); var util_opts = { showHidden : true, depth : 4 }; var taskGroup = false, group = false, sqlTask = frdl.task().ql, cliTask = frdl.task().cli ; var ftp_cmd = 'noop'; var ftp = { }; var ftp_client_id = false; exports.finalize = function(CLI){ group = frdl.task(taskGroup); group.resume(); CLI.emit('cmd.finalized', CLI.data.data); }; exports.prepare = function(CLI){ function closeClient(){ if(ftp.client && ftp.client.close && 'function' === typeof ftp.client.close){ try{ ftp.client.close(); }catch(err){ } } } frdl.alert.error('ftp @Todo - coming soon...!'); CLI.finalState.add('cmd.finalized'); taskGroup = 'test '+ frdl.Guid.newGuid(); group = frdl.task(taskGroup); group.pause(); CLI .addOption('task', 'Apply an task-ID', function(name, value) { taskGroup=frdl.base64_decode(value); CLI.once('catch', function(err){ try{ frdl.task(taskGroup).clearAll(); }catch(e){ } }); }, ' [TEXT]') .addOption('ftp_client_id', 'Apply an ftp_client_id', function(name, value) { ftp_client_id = value; try{ ftp = frdl.cbs[ftp_client_id](); }catch(err){ if(window.XMLHttpRequest){ ftp.client = new XMLHttpRequest(); } else if(window.ActiveXObject){ ftp.client = new ActiveXObject('Microsoft.XMLHTTP'); }else{ console.emit('catch', 'Your browser does not support XMLHttpRequest or ActiveXObject!'); ftp.client = false; } frdl.cbs[ftp_client_id] = function(){ return ftp; }; } }, ' [TEXT]') .once('catch', function(err){ group.clearAll(); }) .once('catch', function(err){ closeClient(); }) .once('success', function(err){ closeClient(); }) .addToken('ftp', '*', function(c, result_length, token, current_option){ ftp_cmd=token; alert(c+' - '+token + ' - ' + result_length); }) .addOption('port', 'Apply an remote port', function(name, value) { ftp.port = value; }, ' [TEXT]') .addOption('host', 'Apply an remote host', function(name, value) { ftp.host = value; }, ' [TEXT]') .addOption('protocol', 'Apply an remote host', function(name, value) { ftp.protocol = value; }, ' [PROTOCOL]') .filter('PROTOCOL', function(value) { var groups = ['ftp', 'sftp', 'api']; return (-1 !== groups.indexOf(value)) ? value : undefined; }) ; };