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 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
- OptionParser.new do |opts|
9
- opts.banner = "Usage: gem_liux1-cli [options] file"
10
- opts.on('-d', '--doing', 'init') do
11
- require 'gem_liux1'
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
- end.parse!(ARGV)
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
@@ -1,3 +1,3 @@
1
1
  module GemLiux1
2
- VERSION = "0.5.6"
2
+ VERSION = "0.5.7"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_liux1
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 6
10
- version: 0.5.6
9
+ - 7
10
+ version: 0.5.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - a