[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:30:25 UTC 2010


The following commit has been merged in the upstream branch:
commit be0ecf84edf051df84792067f6d873a70642872f
Author: Rein Henrichs <reinh at reinh.com>
Date:   Tue Mar 30 15:08:52 2010 -0700

    Initial puppet single executable
    
    - puppet executable delegates to available applications
      and provides basic usage information
    - Puppet::Application.applications accessor added for access by main executable
    - Ugly hack to make RDoc::usage work

diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index 2882c81..0b8e3d9 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -89,7 +89,11 @@ require 'optparse'
 class Puppet::Application
     include Puppet::Util
 
+    SBINDIR = File.expand_path(File.dirname(__FILE__)) + '/../../sbin'
+
     @@applications = {}
+    def self.applications; @@applications end
+
     class << self
         include Puppet::Util
     end
@@ -173,7 +177,7 @@ class Puppet::Application
     def initialize(name, banner = nil, &block)
         @opt_parser = OptionParser.new(banner)
 
-        name = symbolize(name)
+        @name = symbolize(name)
 
         init_default
 
@@ -181,7 +185,7 @@ class Puppet::Application
 
         instance_eval(&block) if block_given?
 
-        @@applications[name] = self
+        @@applications[@name] = self
     end
 
     # initialize default application behaviour
@@ -292,6 +296,12 @@ class Puppet::Application
 
     def help
         if Puppet.features.usage?
+            # RH:FIXME: My goodness, this is ugly.
+            ::RDoc.const_set("PuppetSourceFile", @name)
+            def (::RDoc).caller
+                file = `grep -l 'Puppet::Application\\[:#{::RDoc::PuppetSourceFile}\\]' #{SBINDIR}/*`.chomp
+                super << "#{file}:0"
+            end
             ::RDoc::usage && exit
         else
             puts "No help available unless you have RDoc::usage installed"
diff --git a/sbin/puppet b/sbin/puppet
new file mode 100755
index 0000000..d3472cc
--- /dev/null
+++ b/sbin/puppet
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+appdir = File.join('puppet', 'application')
+builtins = Dir[File.join(appdir, '*.rb')].map{|fn| File.basename(fn, '.rb')}
+
+usage = "Usage: puppet command <space separated arguments>"
+available = "Available commands are: #{builtins.sort.join(', ')}"
+
+command_name = ARGV.empty? || ARGV.first[/^-/] ? nil : ARGV.shift # subcommand?
+if command_name.nil? # main
+    puts usage, available
+elsif builtins.include?(command_name) #subcommand
+    require File.join(appdir, command_name)
+    Puppet::Application[command_name].run
+else
+    abort "Error: Unknown command #{command_name}.\n#{usage}\n#{available}"
+end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list