argv 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/argv/cms.rb +42 -22
- data/sample/test.rb +6 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d1674c456132510816a46e17e273375a62b3af9
|
4
|
+
data.tar.gz: 1fc5186e5020df4394ebc0f1caa6a71c91bb47ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2c3aa823da8edcf2e22f2b624cc04bdc66782061c3ecc9f5a197d120bdd9a9b3200091ed4908d439e7f7dcfd86bd8b0d1dd94eeb31d8baf1ab0cbb15941e521
|
7
|
+
data.tar.gz: dec3f2ea6b21a2537bd27967077905dd9aa195dda3b988390c994cca57c91c37f7e7514813a0568f7f7dff48ce90a3256bc3038a04573d2207d95f92a4bbe6b4
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/lib/argv/cms.rb
CHANGED
@@ -1,36 +1,56 @@
|
|
1
1
|
module ARGVEXT
|
2
|
-
class << self
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
raise unless msg.class <= String
|
7
|
-
@@help_msg_obj.push [msg,keys]
|
8
|
-
return nil
|
9
|
-
end
|
3
|
+
module MemoryCore
|
4
|
+
class << self
|
10
5
|
|
11
|
-
|
6
|
+
@@help_msg_obj ||= []
|
7
|
+
def add_help_msg msg,*keys
|
8
|
+
raise unless msg.class <= String
|
9
|
+
@@help_msg_obj.push [msg,keys]
|
10
|
+
return nil
|
11
|
+
end
|
12
12
|
|
13
|
-
|
13
|
+
def help_msg
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
helper_sym= [:helper,:help,:h]
|
16
|
+
self.add_help_msg "This will show you the help msg (this)",*helper_sym
|
17
|
+
unless ::ARGV.sym_flags.select{ |e| helper_sym.include?(e) }.empty?
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
tmp_ary= []
|
20
|
+
@@help_msg_obj.each{ |ary|
|
21
|
+
tmp_ary.push(ary[0])
|
22
|
+
ary[1].each{|e| tmp_ary.push( ( e.to_s.length == 1 ? "-#{e}" : "--#{e}" ) )}
|
23
|
+
tmp_ary.push("")
|
24
|
+
}
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
tmp_ary.each{ |element| element.include?('--') ? element.gsub!('--',"\t--") : element.gsub!('-',"\t -")}
|
27
|
+
puts "",tmp_ary.join("\n"),""
|
28
|
+
Process.exit!
|
29
29
|
|
30
|
+
end
|
30
31
|
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module MemoryEXT
|
37
|
+
|
38
|
+
def add_help_msg msg,*keys
|
39
|
+
::ARGVEXT::MemoryCore.add_help_msg msg,*keys
|
40
|
+
end
|
41
|
+
|
42
|
+
alias :add_help :add_help_msg
|
43
|
+
|
44
|
+
def help_msg
|
45
|
+
::ARGVEXT::MemoryCore.help_msg
|
31
46
|
end
|
32
47
|
|
33
48
|
alias :show_help :help_msg
|
34
49
|
|
35
50
|
end
|
36
|
-
|
51
|
+
|
52
|
+
self.extend MemoryEXT
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
ARGV.__send__ :extend, ARGVEXT::MemoryEXT
|
data/sample/test.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
require "argv"
|
2
2
|
|
3
3
|
#$ ruby sample/test.rb --test test this ok
|
4
|
-
|
4
|
+
|
5
|
+
# new help
|
6
|
+
ARGV.add_help "heeeelp meeeeee~~~",:no
|
7
|
+
|
8
|
+
ARGV.show_help
|
5
9
|
|
6
10
|
puts "","original ARGV:",ARGV.inspect,""
|
7
11
|
|
@@ -23,4 +27,4 @@ puts "argv values without the tags:",ARGV.values.inspect,""
|
|
23
27
|
puts "argv tags, \"keys\":",ARGV.keys.inspect,""
|
24
28
|
# ["--test"]
|
25
29
|
|
26
|
-
puts "symbolized flags:",ARGV.sym_flags.inspect,""
|
30
|
+
puts "symbolized flags:",ARGV.sym_flags.inspect,""
|