From 264a43c835a8131f3a2df5b5cf5c29c8bfcabb67 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 8 Feb 2011 16:26:10 -0800 Subject: Renaming "data" app to "interface" Signed-off-by: Luke Kanies --- lib/puppet/application/data.rb | 93 ------------------------------------- lib/puppet/application/interface.rb | 93 +++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 93 deletions(-) delete mode 100644 lib/puppet/application/data.rb create mode 100644 lib/puppet/application/interface.rb (limited to 'lib/puppet') diff --git a/lib/puppet/application/data.rb b/lib/puppet/application/data.rb deleted file mode 100644 index 8d98d4416..000000000 --- a/lib/puppet/application/data.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'puppet/application' - -class Puppet::Application::Data < Puppet::Application - - should_parse_config - run_mode :agent - - option("--debug", "-d") do |arg| - Puppet::Util::Log.level = :debug - end - - option("--verbose", "-v") do - Puppet::Util::Log.level = :info - end - - def list(*arguments) - if arguments.empty? - arguments = %w{terminuses actions} - end - indirections.each do |ind| - str = "#{ind}:\n" - if arguments.include?("terminuses") - begin - terms = terminus_classes(ind.to_sym) - str << "\tTerminuses: #{terms.join(", ")}\n" - rescue => detail - $stderr.puts "Could not load terminuses for #{ind}: #{detail}" - end - end - - if arguments.include?("actions") - begin - actions = actions(ind.to_sym) - str << "\tActions: #{actions.join(", ")}\n" - rescue => detail - $stderr.puts "Could not load actions for #{ind}: #{detail}" - end - end - - print str - end - exit(0) - end - - attr_accessor :verb, :name, :arguments - - def main - # Call the method associated with the provided action (e.g., 'find'). - send(verb, *arguments) - end - - def setup - Puppet::Util::Log.newdestination :console - - load_applications # Call this to load all of the apps - - @verb, @arguments = command_line.args - @arguments ||= [] - - validate - end - - def validate - unless verb - raise "You must specify 'find', 'search', 'save', or 'destroy' as a verb; 'save' probably does not work right now" - end - - unless respond_to?(verb) - raise "Command '#{verb}' not found for 'data'" - end - end - - def indirections - Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort - end - - def terminus_classes(indirection) - Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort - end - - def actions(indirection) - return [] unless interface = Puppet::Interface.interface(indirection) - interface.load_actions - return interface.actions.sort { |a,b| a.to_s <=> b.to_s } - end - - def load_applications - command_line.available_subcommands.each do |app| - command_line.require_application app - end - end -end - diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb new file mode 100644 index 000000000..8d98d4416 --- /dev/null +++ b/lib/puppet/application/interface.rb @@ -0,0 +1,93 @@ +require 'puppet/application' + +class Puppet::Application::Data < Puppet::Application + + should_parse_config + run_mode :agent + + option("--debug", "-d") do |arg| + Puppet::Util::Log.level = :debug + end + + option("--verbose", "-v") do + Puppet::Util::Log.level = :info + end + + def list(*arguments) + if arguments.empty? + arguments = %w{terminuses actions} + end + indirections.each do |ind| + str = "#{ind}:\n" + if arguments.include?("terminuses") + begin + terms = terminus_classes(ind.to_sym) + str << "\tTerminuses: #{terms.join(", ")}\n" + rescue => detail + $stderr.puts "Could not load terminuses for #{ind}: #{detail}" + end + end + + if arguments.include?("actions") + begin + actions = actions(ind.to_sym) + str << "\tActions: #{actions.join(", ")}\n" + rescue => detail + $stderr.puts "Could not load actions for #{ind}: #{detail}" + end + end + + print str + end + exit(0) + end + + attr_accessor :verb, :name, :arguments + + def main + # Call the method associated with the provided action (e.g., 'find'). + send(verb, *arguments) + end + + def setup + Puppet::Util::Log.newdestination :console + + load_applications # Call this to load all of the apps + + @verb, @arguments = command_line.args + @arguments ||= [] + + validate + end + + def validate + unless verb + raise "You must specify 'find', 'search', 'save', or 'destroy' as a verb; 'save' probably does not work right now" + end + + unless respond_to?(verb) + raise "Command '#{verb}' not found for 'data'" + end + end + + def indirections + Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort + end + + def terminus_classes(indirection) + Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort + end + + def actions(indirection) + return [] unless interface = Puppet::Interface.interface(indirection) + interface.load_actions + return interface.actions.sort { |a,b| a.to_s <=> b.to_s } + end + + def load_applications + command_line.available_subcommands.each do |app| + command_line.require_application app + end + end +end + -- cgit