diff options
-rw-r--r-- | lib/puppet/application/indirection_base.rb | 7 | ||||
-rw-r--r-- | lib/puppet/application/interface_base.rb | 2 | ||||
-rw-r--r-- | spec/unit/application/interface_base_spec.rb | 12 |
3 files changed, 14 insertions, 7 deletions
diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index 3e907696e..e6d172ced 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -8,13 +8,6 @@ class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase attr_accessor :from, :indirection - def main - # Call the method associated with the provided action (e.g., 'find'). - result = interface.send(verb, name, *arguments) - render_method = Puppet::Network::FormatHandler.format(format).render_method - puts result.send(render_method) if result - end - def setup super diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 044249d39..70022f17d 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -61,6 +61,8 @@ class Puppet::Application::InterfaceBase < Puppet::Application @verb, @arguments = command_line.args @arguments ||= [] + @arguments = Array(@arguments) + @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym unless @interface = Puppet::Interface.interface(@type) diff --git a/spec/unit/application/interface_base_spec.rb b/spec/unit/application/interface_base_spec.rb index 4ef3869c2..1717f4982 100644 --- a/spec/unit/application/interface_base_spec.rb +++ b/spec/unit/application/interface_base_spec.rb @@ -14,6 +14,7 @@ describe Puppet::Application::InterfaceBase do @app.stubs(:interface).returns base_interface @app.stubs(:exit) @app.stubs(:puts) + Puppet::Util::Log.stubs(:newdestination) end describe "when calling main" do @@ -40,6 +41,17 @@ describe Puppet::Application::InterfaceBase do @app.stubs(:validate) end + it "should set the verb from the command line arguments" do + @app.setup + @app.verb.should == "find" + end + + it "should make sure arguments are an array" do + @app.command_line.stubs(:args).returns(["find", "myname"]) + @app.setup + @app.arguments.should == ["myname"] + end + it "should set the options on the interface" do @app.options[:foo] = "bar" @app.setup |