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:

  1. Resume is usually handy for use in chain calls, not as something to

present for the user to access directly.  It resumes paused commands.
  1. 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.
  1. 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.  +set+ +optionname+ returns
the current value, +set+ +optionname+ +value+ sets the value of
+optionname+

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()