#4 ✓invalid
bahuvrihi

Command interface

Reported by bahuvrihi | March 10th, 2009 @ 09:23 PM

This is a good default interface:


CmdUtils.CreateCommand({
  name: "name",
  description: "summary",
  help: "content",
  takes: {"what": noun_arb_text},
  execute: function(what) {
    // dispatch to server
  }
})

Mapping to:


# ::ubiquity summary
# content
def cmd(what)
  # returns {:inject, :script}
end

Advanced features include: * determination of 'what' name from method * determination of mods using from method (see below) * determining noun types from a comment signature (# what:: noun type) * asynchronous noun type suggestion (map to some method) * regexp noun type suggestion * specification of text, html, or summary to provide for what (default text)

Determining mods from method

Proposal maps:


def cmd(what, in=, where=)
end

To:


CmdUtils.CreateCommand({
  takes: {"what": noun_arb_text},
  modifiers: {"in": noun_arb_text, "where": noun_arb_text},
  execute: function(what, mods) {
    // dispatch to server
  }
})

Additional specifications

Could perhaps do it through lazydoc. Upside is that it can be loaded without loading the code. Downside is that it's harder to test and such.

Could make it a method... downside is the code has to be loaded.

Could make a cmd.js file in views. This is perhaps best. It can be rendered if it exists, to specify special behaviors. This is the most flexible option, and in fact leads to the possibility of simply registering commands.


  # Sample::ubiqity description

  [views/sample/cmd.js]

The cmd is rendered, if it exists, and default properties are set if they don't already exist.

Actually, to be more clear:


  [views/sample/cmd.js]    # renders full command, substitute in
  [views/sample/cmd.json]  # simply specifies the options, merge with defaults

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Interaction with Tap from Ubiquity.

People watching this ticket

Pages