Module: Command::StandardCommands
- Defined in:
- lib/command-set/standard-commands.rb
Overview
This is a collection of useful commands that are often useful to add to DSL::CommandSetDefinition#include_commands
For instance
set = CommandSet::define_commands do include_commands Command::StandardCommands::Quit include_commands Command::StandardCommands::Undo include_commands Command::StandardCommands::Help end
Or you could use Command::DSL::require_commands, like so
set = CommandSet::define_commands do require_commands "StdCmd::Quit", "command-set/standard_commands", require_commands "StdCmd::Undo" require_commands "StdCmd::Help" end
Some notes:
- Resume is usually handy for use in
chaincalls, not as something to present for the user to access directly. It resumes paused commands. - Mode is useful in subcommands. Including it lets the user use the subcommand by itself to switch into a mode where that subcommand is the root command set. Then "exit" lets them leave and return to the regular set. Consider IOS's config mode, for instance.
- Set is useful for allowing the user to update program settings on the
fly. It assumes a set of nested hashes that represent the settings.
It functions as you'd (hopefully) expect.
setoptionnamereturns the current value,setoptionnamevaluesets the value ofoptionname
Constant Summary collapse
- Help =
StdCmd::Help.define_commands()
- Resume =
StdCmd::Resume.define_commands()
- Quit =
StdCmd::Quit.define_commands()
- Undo =
StdCmd::Undo.define_commands()
- Mode =
StdCmd::Mode.define_commands()
- Set =
StdCmd::Set.define_commands()