Sha256: 2330607c1d753eb34b4b8101c53dcbfbe4c1424896bdde94d4b4b859afe2a8bc

Contents?: true

Size: 1.82 KB

Versions: 18

Compression:

Stored size: 1.82 KB

Contents

#coding=utf-8

module Aio::Ui

	class Banner

		attr_accessor :mode
		attr_accessor :type
		attr_accessor :input_style, :input
		attr_accessor :ranking
		attr_accessor :output_style, :output
		attr_accessor :compare
		
		def banner
			res = %Q^
Usage: ./aio [option] <var>

Options:
	-l,   --list              [type]            显示所有或者所选type类型的模块信息
	-c,   --compare           <path1>           被比较的文件路径
	-is,  --input-style       <mod>             输入的模块名称
	-i,   --input             <path>            输入信息的绝对路径
	-r,   --ranking           <level>           选择命令的级别
	-os,  --output-style      <mod>             输出的模块名称
	-o,   --output            <path>            输出信息的路径
	-h,   --help                                帮助
^
			print res
			exit 0
		end

		def initialize
			@type = ""
		end

		def parse(args=[])
			banner if args.empty?

			while(!args.empty?) do 
				arg = args.shift
				case arg
				when "-l", "--list"
					@type = args.shift unless args[0] =~ /-/
					self.mode = 0
				when "-is", "--inupt-style"
					@input_style = check(args.shift)
					self.mode = 1
				when "-i", "--input"
					@input = check(args.shift)
				when "-r", "--ranking"
					@ranking = check(args.shift)
				when "-c", "--compare"
					@compare = check(args.shift)
				when "-os", "--output-style"
					@output_style = check(args.shift)
					self.mode = 1
				when "-o", "--output"
					@output = check(args.shift)
				when "-h", "--help"
					banner
				end
			end

			self
		end

		# 检查参数是否合法
		def check(opt)
			opt = opt.to_s
			if opt.empty? and opt =~ /-/
				banner
			end

			return opt
		end

		# 判断是否有 input 信息
		def has_input?
			return false if @input_style.nil? and @input.nil?
			return true
		end
			
	end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
aio_elin-1.1.8 lib/aio/ui/banner.rb
aio_elin-1.1.7 lib/aio/ui/banner.rb
aio_elin-1.1.4 lib/aio/ui/banner.rb
aio_elin-1.1.3 lib/aio/ui/banner.rb
aio_elin-1.1.2 lib/aio/ui/banner.rb
aio_elin-1.1.1 lib/aio/ui/banner.rb
aio_elin-1.1.0 lib/aio/ui/banner.rb
aio_elin-1.0.9 lib/aio/ui/banner.rb
aio_elin-1.0.8 lib/aio/ui/banner.rb
aio_elin-1.0.7 lib/aio/ui/banner.rb
aio_elin-1.0.6 lib/aio/ui/banner.rb
aio_elin-1.0.5 lib/aio/ui/banner.rb
aio_elin-1.0.4 lib/aio/ui/banner.rb
aio_elin-1.0.3 lib/aio/ui/banner.rb
aio_elin-1.0.2 lib/aio/ui/banner.rb
aio_elin-1.0.1 lib/aio/ui/banner.rb
aio_elin-1.0.0 lib/aio/ui/banner.rb
aio_elin-0.0.1 lib/aio/ui/banner.rb