Class: Roby::Interface::ShellSubcommand

Inherits:
SubcommandClient show all
Defined in:
lib/roby/interface/shell_subcommand.rb

Overview

Representation of a subcommand on Interface on the shell side

Instance Attribute Summary

Attributes inherited from SubcommandClient

#commands, #description, #name, #parent

Instance Method Summary collapse

Methods inherited from SubcommandClient

#initialize, #path

Constructor Details

This class inherits a constructor from Roby::Interface::SubcommandClient

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/roby/interface/shell_subcommand.rb', line 9

def method_missing(m, *args)
    parent.call(Hash.new, [name], m, *args)
rescue NoMethodError => e
    if e.message =~ /undefined method .#{m}./
        puts "invalid command name #{m}, call 'help #{path.join(".")}' for more information"
    else raise
    end
rescue ArgumentError => e
    if e.message =~ /wrong number of arguments/ && e.backtrace.first =~ /#{m.to_s}/
        puts e.message
    else raise
    end
end

Instance Method Details

#call(options, path, m, *args) ⇒ Object



5
6
7
# File 'lib/roby/interface/shell_subcommand.rb', line 5

def call(options, path, m, *args)
    parent.call(options, [name] + path, m, *args)
end