synccommand-934965: Allow predictions to be an array

Previously we demanded that they were a promise that resolved to an
array or a function that returned an array, but you could use just an
array.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
synccommand-934965: Move command type functions to top level

This allows us to enable their use by other modules, like
requisition._split.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
synccommand-934965: Use CommandType to make _split synchronous

The promises on which we need to call util.synchronize can be removed by
directly using CommandType.parse() rather than
commandAssignment.param.type.parse()

Signed-off-by: Joe Walker <jwalker@mozilla.com>
synccommand-934965: Make setting blank assignments synchronous

The process of setting an assignment to blank was a bit ambiguous as to
whether it could be done synchronously. This clarifies that it can.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
syncincdec-830184: Make increment and decrement asynchronous

This is mostly a simple matter of chasing a (surprisingly short) chain
of return statements using promises instead.
It also adds functions to the list of remoted function.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
syncincdec-830184: Make stringify asynchronous

Also a simple matter of chasing a chain of return statements and using
promises instead.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
syncincdec-830184: Expose selection type functions

Much of the type processing is synchronous, but the interface is
specified in terms of promises to allow for remote usage. This change
refactors some synchronous parts to be usable from the outside for cases
where we don't need remote usage:

* command.js - getDisplayedParamLookup
* selection.js - findPredictions and convertPredictions

Signed-off-by: Joe Walker <jwalker@mozilla.com>
syncincdec-830184: Use type functions directly to avoid async parse

UnassignedAssignment used to have a util.synchronize because it knew
that parse happened synchronously. But using the type functions directly
allows us to get rid of that.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: fields.getFields doesn't need those options

Now that we've greatly trimmed down the number of fields, we don't need
to pass in that large block of data.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Review fixes

See https://github.com/joewalker/gcli/pull/16 for details.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Various minor fixes

Fix error message in cli.js.
Wrap comment in setting.js.
Move setup of return value in terminal.js.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Process backspace in keydown not keyup

Some time ago (see “Enable backspace to return to parent language”) we
made it so pressing ‘:<BACKSPACE>’ in javascript mode would take you
into command mode and then back again, but processing that in keyup
meant that the (value === '') test would also be true if the user
pressed ‘x<BACKSPACE>’.

This change also moves the job of resetting the input to ‘’ from
command.js (where it was causing problems with synchronised promises) to
languages.js (where it can be shared by all languages)

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Add <BACKSPACE> testing

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Run setup/post in non-global scope

Now they run in the scope of the containing object (lexically speaking)

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Add missing returns to setup functions

helpers.setInput returns a promise, so we need to pass those promises
on to hold up testing until setInput has really finished. When we move
to fully async promises, we will need this.
syncincdec-830184: Make _assign properly asynchronous

Previously there was an ‘outstanding’ array in which we collected
promises of setAssignments that were not complete, and we finished with
‘promise.all(outstanding);’. However that allows the setAssignment calls
to complete in any order, which breaks delegated types which are allowed
to know about other assignments (which are now in an ambiguous state).
So we switch to using util.promiseEach which processes each pass of the
array in order before moving on to the next.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
syncincdec-830184: Checking 'completed' is pointless when async

When we switch to properly async promises, it won’t make any sense to
check for completed any more because everything will be async.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
syncincdec-830184: Comment out tests depending on bug 935990

There are a couple of places where asynchronous output is used in a
template, however the domtemplate engine doesn’t make it easy for us to
know when these updates are completed. Since these issues don’t
represent real world bugs, we’re commenting the tests out until a fix
is ready.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
syncincdec-830184: Move to a fully async promise

promise.js is now a hacked about version of mozilla-central’s
Promise.jsm, we no longer have util.synchronize and when building files
into mozilla-central we use the central version of Promise.jsm rather
than our copy.

Signed-off-by: Joe Walker <jwalker@mozilla.com>