Module: IRB::ExtendCommandBundle
- Defined in:
- lib/irgat/console.rb
Instance Method Summary collapse
-
#irgat_help(what = nil) ⇒ Object
irgat_help.
Instance Method Details
#irgat_help(what = nil) ⇒ Object
irgat_help. Load a file with help about command
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/irgat/console.rb', line 5 def irgat_help(what=nil) # TODO check paths help_file=IRGAT_LANG+"/help_cmd_#{@config[:lang]}.rb" # control if exist file if ! test(?d,help_file) puts "Help file #{help_file} not found. Check the install or choose another language in your irgat config file" end #get comments in file comment = File.open(help_file) do |file| RDoc.find_comment(file) end # parse it, and create needed objects comment = comment.gsub(/^\s*#/, '') markup = SM::SimpleMarkup.new flow_convertor = SM::ToFlow.new flow = markup.convert(comment, flow_convertor) #define output format format = "plain" #index help if nothing was wrotten what='index' if what==nil #i don't want output in these... $stdout=File.new('/dev/null',"w+") searched_flow = RDoc.extract_sections(flow, what.to_a) #retake output $stdout=STDOUT # i don't like the rdoc way to return the things... it is assumed, that if you don't found your desired section, you want to see all!! O_o if flow==searched_flow puts '[ Error ] No section founded for your petition '+what puts 'Try a diffent pattern search or try irgat_help without search pattern to view a list of avaibles sections' else #we have found, render it = RI::Options.instance if args = ENV["RI"] .parse(args.split) end formatter = .formatter.new(, "") formatter.display_flow(searched_flow) end end |