Sha256: 70090d76861568c84feea4ef319779b5e22cd176aba0a42aa40d6d0aa50fb5cf

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

# -*- coding: utf-8 -*-
require "optparse"
require "yaml"
require 'my_help/org2yml'
require 'my_help/yml2org'
require 'my_help/my_help_controll'
require "fileutils"
require "my_help/version"
require "systemu"
require "colorize"

module MyHelp
  class Command
    def self.run(argv=[])
      new(argv).execute
    end

    def initialize(argv=[])
      @argv = argv
      @control = MyHelp::Control.new(argv)
    end

    def execute
      @argv << '--help' if @argv.size==0
      command_parser = OptionParser.new do |opt|
        opt.on('-v', '--version','show program Version.') { |v|
          opt.version = MyHelp::VERSION
          puts opt.ver
        }
        opt.on('-l', '--list [FILE]', 'list all helps or FILE'){|file| @control.list_helps(file)}
        opt.on('-i ITEM', '--item NAME', 'show NAME item'){|item| @item = item}
        opt.on('-s FILE', '--show FILE', 'show FILE'){|file| @control.show(file, @item)}
        opt.on('-e NAME', '--edit NAME', 'edit NAME help(eg test_help)'){|file| @control.edit_help(file) }
        opt.on('-m NAME', '--make NAME', 'make NAME help(eq test_help)'){|file| @control.init_help(file)}
        opt.on('-y', '--yml2org [FILE]', 'convert FILE from yaml to org format'){|file| yml2org(file)}
        opt.on('--delete NAME','delete NAME help'){|file| @control.delete_help(file)}
      end
      begin
        command_parser.parse!(@argv)
      rescue=> eval
        p eval
      end
      exit
    end

    def yml2org(file)
      p target = File.join(@local_help_dir,file+'.yml')
      cont = YmlToOrg.new(target).contents
      dump = file+'.org'
      File.open(dump, 'w'){|file| file.print cont }
      delete_help(file)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
my_help-0.7.1 before_gli/lib/my_help_new.rb
my_help-0.7.0 before_gli/lib/my_help_new.rb