faketerminal
faketerminal copied to clipboard
how we can use `requestPassword`?
My sample:
window.FakeTerminal.command.ops = function (instance) {
// Extend the base command
window.FakeTerminal.command.apply(this, arguments);
var base = this;
base.info = function () {
return {
private: false,
description: 'This command doesn\'t do anything terribly exciting'
};
};
base.execute = function (foo, bar) {
instance.output.write('The value of foo is: ' + foo);
instance.output.write('The value of bar is: ' + bar);
base.deferred.resolve();
var xx = '';
var ss = instance.input.requestPassword(xx);
return base.deferred.promise();
};
return base;
};
What's the problem?
@A1Gard have you figured this out yet? @hellopablo how do we check the value of the password?
@A1Gard i found the solution:
window.FakeTerminal.command.shutdown = function (instance) {
window.FakeTerminal.command.apply(this, arguments);
var base = this;
base.info = function () {
return {
private: false,
description: 'This command shuts the os down.'
};
};
base.execute = function () {
instance.output.write(`<question>Please enter your password:</question>`);
instance.input.request("password").done(function(value) {
if (value == "AtyysCyBDnESysTmsT1000") {
instance.output.write(`<info>Initiating shutdown sequence...</info>`);
base.deferred.resolve();
} else {
instance.output.write(`<error>ERROR: Aborting shutdown sequence.</error>`);
instance.output.write(`<error>ERROR: Incorrect password.</error>`);
base.deferred.resolve();
};
}).fail(function() {
instance.output.write("ERROR FATAL");
base.deferred.resolve();
});
return base.deferred.promise();
};
return base;
};
Thanks @oxmc - sorry @A1Gard I've not had/made time to look at this repository in years (literally).
I do want to revisit this project and bring it to the modern world... one day 😅
@hellopablo if you do look into the repo, please create a docs site, like xterm.js
So users can refer to it.