Class: Climate::Help::Man::Script

Inherits:
Command
  • Object
show all
Defined in:
lib/climate/help/man.rb

Overview

Eat my own dog food

Instance Attribute Summary

Attributes inherited from Command

#arguments, #argv, #leftovers, #options, #parent, #stderr, #stdin, #stdout

Instance Method Summary collapse

Methods inherited from Command

add_subcommand, #ancestor, ancestors, arg, class_name, description, disable_parsing, has_subcommands?, #initialize, name, run, subcommand_of, subcommands

Methods included from ParsingMethods

#arg, #cli_arguments, #cli_options, #has_arguments?, #has_options?, #opt, #parse, #parse_arguments, #stop_on, #trollop_parser

Constructor Details

This class inherits a constructor from Climate::Command

Instance Method Details

#runObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/climate/help/man.rb', line 27

def run
  out_file = (of = options[:out_file]) && File.open(of, 'w') || $stdout

  command_class = arguments[:command_class].split('::').
    inject(Object) {|m,v| m.const_get(v) }

  template_file = options[:template] || File.join(
    File.dirname(__FILE__), 'man.erb')

  Man.new(command_class, :output => out_file,
    :template_file => template_file).print
end