lib/zan_tools/command.rb in zan_tools-0.1.1 vs lib/zan_tools/command.rb in zan_tools-0.1.2

- old
+ new

@@ -12,11 +12,10 @@ def parse! parser = OptionParser.new do |opts| opts.banner = "Usage zan_tools COMMAND [options]" opts.separator "COMMAND" opts.separator " g/generate: 根据指定模板生成代码" - opts.separator "generate options" # generate命令参数 opts.on("-n", "--name NAME", "表名或者类名") do |value| options[:name] = value end @@ -28,19 +27,25 @@ options[:template] = File.read(value) else raise "template file not exists" end end + opts.separator "common options" # 其他参数 opts.on("-o", "--output FILE", "输出到指定文件") do |value| options[:output] = value end + opts.on("-v", "--version", "zan_tools版本") do |value| + options[:version] = ZanTools::VERSION + end end parser.parse! case ARGV[0] when 'g', 'generate' generate + else + puts options[:version] if options[:version] end rescue StandardError => e puts [e.class, e.message].join(': ') end \ No newline at end of file