gem_liux1 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/gem_liux1-cli +38 -8
- data/lib/gem_liux1/version.rb +1 -1
- metadata +3 -3
data/bin/gem_liux1-cli
CHANGED
@@ -1,13 +1,43 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: UTF-8
|
3
|
-
require 'sass'
|
4
|
-
require 'gem_liux1'
|
5
|
-
require 'yaml'
|
3
|
+
# require 'sass'
|
4
|
+
# require 'gem_liux1'
|
5
|
+
# require 'yaml'
|
6
|
+
# require 'optparse'
|
7
|
+
|
8
|
+
# OptionParser.new do |opts|
|
9
|
+
# opts.banner = "Usage: gem_liux1-cli [options] file"
|
10
|
+
# opts.on('-d', '--doing', 'init') do
|
11
|
+
# require 'gem_liux1'
|
12
|
+
# end
|
13
|
+
# end.parse!(ARGV)
|
14
|
+
|
15
|
+
|
6
16
|
require 'optparse'
|
7
17
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
18
|
+
options = {}
|
19
|
+
option_parser = OptionParser.new do |opts|
|
20
|
+
# 这里是这个命令行工具的帮助信息
|
21
|
+
opts.banner = 'here is help messages of the command line tool.'
|
22
|
+
|
23
|
+
# Option 作为switch,不带argument,用于将 switch 设置成 true 或 false
|
24
|
+
options[:switch] = false
|
25
|
+
# 下面第一项是 Short option(没有可以直接在引号间留空),第二项是 Long option,第三项是对 Option 的描述
|
26
|
+
opts.on('-s', '--switch', 'Set options as switch') do
|
27
|
+
# 这个部分就是使用这个Option后执行的代码
|
28
|
+
options[:switch] = true
|
12
29
|
end
|
13
|
-
|
30
|
+
|
31
|
+
# Option 作为 flag,带argument,用于将argument作为数值解析,比如"name"信息
|
32
|
+
#下面的“value”就是用户使用时输入的argument
|
33
|
+
opts.on('-n NAME', '--name Name', 'Pass-in single name') do |value|
|
34
|
+
options[:name] = value
|
35
|
+
end
|
36
|
+
|
37
|
+
# Option 作为 flag,带一组用逗号分割的arguments,用于将arguments作为数组解析
|
38
|
+
opts.on('-a A,B', '--array A,B', Array, 'List of arguments') do |value|
|
39
|
+
options[:array] = value
|
40
|
+
end
|
41
|
+
end.parse!
|
42
|
+
|
43
|
+
puts options.inspect
|
data/lib/gem_liux1/version.rb
CHANGED
metadata
CHANGED