cli: update usage message to include "expect" option

Signed-off-by: Peter Williams <pwil3058@gmail.com>
grammar: reorder generated code to enable stateful parts to be nestable
inside functions as well as class definitions.
Add an example that uses this feature.

Signed-off-by: Peter Williams <pwil3058@gmail.com>