ruby_cli 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/hello_world +0 -1
- data/lib/ruby_cli.rb +11 -7
- metadata +2 -2
data/examples/hello_world
CHANGED
data/lib/ruby_cli.rb
CHANGED
@@ -36,12 +36,11 @@ module RubyCLI
|
|
36
36
|
output_help(1)
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
40
|
-
#
|
41
|
-
|
42
|
-
def parse_options?
|
39
|
+
|
40
|
+
# Redefine this method if you want to add command specific options
|
41
|
+
def define_option_parser
|
43
42
|
#configure an OptionParser
|
44
|
-
|
43
|
+
OptionParser.new do |opts|
|
45
44
|
opts.banner = "Usage: #{@command_name} [OPTIONS]... [ARGUMENTS]..."
|
46
45
|
opts.separator ""
|
47
46
|
opts.separator "Specific options:"
|
@@ -52,8 +51,13 @@ module RubyCLI
|
|
52
51
|
opts.on('-V','--verbose','Run verbosely') do
|
53
52
|
@default_options[:verbose] = true
|
54
53
|
end
|
55
|
-
# If you redefine, you can add command specific options here!
|
54
|
+
# If you redefine, you can copy this method and add command specific options here!
|
56
55
|
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Parse the options
|
59
|
+
def parse_options?
|
60
|
+
@opt_parser = define_option_parser
|
57
61
|
@opt_parser.parse!(@default_argv) rescue return false
|
58
62
|
return true
|
59
63
|
end
|
@@ -81,7 +85,7 @@ module RubyCLI
|
|
81
85
|
# Redefine if you need to process options.
|
82
86
|
def process_options() return true end
|
83
87
|
|
84
|
-
# Redefine if you need to process
|
88
|
+
# Redefine if you need to process arguments.
|
85
89
|
def process_arguments() return true end
|
86
90
|
|
87
91
|
# Application logic
|