Module: StdCmd::Mode

Defined in:
lib/command-set/standard-commands.rb

Constant Summary collapse

@@set =
nil

Class Method Summary collapse

Class Method Details

.define_commandsObject



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/command-set/standard-commands.rb', line 129

def self.define_commands
  return @@set ||= Command::CommandSet.define_commands do
    root_command do
      argument(Command::FiddlyArgument.new(:mode) do |argument|
        argument.completion do |t,s|
          []
        end

        argument.validation do |term,s|
          Command::CommandSet === term
        end
      end)
      subject_methods :interpreter
      doesnt_undo

      action do
        subject.interpreter.push_mode(mode)
      end
    end

    command(:exit) do
      subject_methods :interpreter
      doesnt_undo

      action do
        subject.interpreter.pop_mode
      end
    end
  end  
end