From MozillaWiki
< Labs‎ | Bespin‎ | DesignDocs
Jump to: navigation, search

Design Document: Accessing and running commands


One of the main extension points for Bespin is through Ubiquity-like commands. We need a way for end users to install and tweak their commands. There are many ways that we could do this. Here is a first stab:

Commands are placed in: BespinSettings/commands/COMMAND_NAME.js.

cmdload commandname

Given a commandname, load up the given command (BespinSettings/commands/commandname.js) and install it into the running command line.

Here is what the calculate:

   name: 'calculate',
   takes: ['expr'],
 //    type: [Bespin.Commands.Editor, Bespin.Commands.Dashboard],
   preview: 'calculate some simple math',
   execute: function(self, expr) {
       if (!expr) {
           self.showInfo('Please give me something to calculate dood!');
       } else {
           self.showInfo('Calculating ' + expr + '<br><br>Result: ' + eval(expr));        

TODO: We should also support:

  • multiple commands (cmdload foo bar baz)
  • A url as well as a command name (cmdload To do this we have cross domain issues, so for now we would use JSON/P and make sure that the command is wrapped in "_commandLine.addCommands([ // PUT THE COMMAND HERE ])"

cmdedit commandname

This opens up an existing command, or creates a new one if it doesn't exist. Make your change, and then 'save' away to make the command ready for loading.


This command shows you the commands that you have available for loading.

cmdrm commandname

Remove the custom command already!

TODO: cmdrunselection

Select a command in the editor, and run it. Must select an object for the command, so don't include the _commandLine.addCommands([ .... ])


auto load commands

You may want to autoload particular commands. To do this, simply load the puppies via your config.js.

Do this:

  • editconfig
    • Add something like:
    •"command:load", { commandname: "calculate" });
  • save
  • runconfig

Installing commands based on the type

We need to support adding commands only in a given type (editor, dashboard).

You will see that above we commented out the type: [...] item. We need to work out if that is the right way to go.