Im trying to find a way that when you try this command:
custprmt: function(pstr, ifbold) {
if(ifbold === '-makebold') {
localStorage.setItem('myNEWprompt', pstr);
this.set_prompt('[[b;var;]' + pstr +' ')
}
else {
localStorage.setItem('myNEWprompt', pstr);
this.set_prompt(pstr +' ')
}
},
It will make a custom prompt based off what the user types, and save it to local storage. Then by using this code:
$(document).ready(function () {
if (myNEWprompt) {
set_prompt(myNEWprompt)
} else {
set_prompt('guest$ ')
}
});
It will load the custom prompt on page load. My issue is that the second set of code isnt loading the prompt that is saved. I feel like it might be because of the set_prompt
but im not sure, ive tried this.set_prompt
and prompt:
but none works. Im not really sure what to do anymore, and I dont know if its even possible, so please help, your assistance will be much appreciated :)
It looks like you want to have command with options. There is helper methods for that
$.terminal.parse_options()
.You're code can look like this:
but note that options with long names require a double dash. So you need to type:
Quotes for the prompt are needed if you want to have a space after the prompt.
Here is a working demo.
When you parse options you have a similar syntax to Yargs.
You have an object with each option as a field if the option is a flag it has a true or false value or if it's an option with an argument it has a string as a value. In case of a boolean option like in your case you can use a second argument to indicate that the option is boolean so it can be used before the normal argument.
Example:
When using this you can have a command that looks like this:
And the output will be the same, the makebold option will be a boolean flag.