diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2011-06-08 18:47:44 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2011-06-08 18:47:44 -0700 |
| commit | 649b3dc58349d3bbb1bd28bf882013c2cf5b8000 (patch) | |
| tree | 1f047edff3c51258b3367a1d5c9f5cfbb02b4c71 /lib/puppet/interface | |
| parent | e0573603c5780e79c2461ece604c6388e4222504 (diff) | |
| parent | 8ccd00963d91f168438eaec4b29a18cd4a1ac583 (diff) | |
| download | puppet-649b3dc58349d3bbb1bd28bf882013c2cf5b8000.tar.gz puppet-649b3dc58349d3bbb1bd28bf882013c2cf5b8000.tar.xz puppet-649b3dc58349d3bbb1bd28bf882013c2cf5b8000.zip | |
Merge branch '2.7.x'
Diffstat (limited to 'lib/puppet/interface')
| -rw-r--r-- | lib/puppet/interface/action.rb | 23 | ||||
| -rw-r--r-- | lib/puppet/interface/documentation.rb | 31 |
2 files changed, 32 insertions, 22 deletions
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 748888c2e..185302b07 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -48,28 +48,7 @@ class Puppet::Interface::Action attr_doc :returns attr_doc :arguments def synopsis - output = PrettyPrint.format do |s| - s.text("puppet #{@face.name}") - s.text(" #{name}") unless default? - s.breakable - - options.each do |option| - option = get_option(option) - wrap = option.required? ? %w{ < > } : %w{ [ ] } - - s.group(0, *wrap) do - option.optparse.each do |item| - unless s.current_group.first? - s.breakable - s.text '|' - s.breakable - end - s.text item - end - end - end - s.text(" #{arguments}") if arguments - end + build_synopsis(@face.name, default? ? nil : name, arguments) end ######################################################################## diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb index fcaec2568..47e478a44 100644 --- a/lib/puppet/interface/documentation.rb +++ b/lib/puppet/interface/documentation.rb @@ -61,6 +61,37 @@ class Puppet::Interface end attr_doc :description + + def build_synopsis(face, action = nil, arguments = nil) + output = PrettyPrint.format do |s| + s.text("puppet #{face}") + s.text(" #{action}") unless action.nil? + s.text(" ") + + options.each do |option| + option = get_option(option) + wrap = option.required? ? %w{ < > } : %w{ [ ] } + + s.group(0, *wrap) do + option.optparse.each do |item| + unless s.current_group.first? + s.breakable + s.text '|' + s.breakable + end + s.text item + end + end + + s.breakable + end + + if arguments then + s.text arguments.to_s + end + end + end + end module FullDocs |
