cli-topic 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/clitopic/command/base.rb +0 -1
- data/lib/clitopic/commands.rb +2 -0
- data/lib/clitopic/parser/option_parser.rb +20 -2
- data/lib/clitopic/version.rb +1 -1
- 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: d33cb99755097e7f69ff49226238d5c488c61d70
|
4
|
+
data.tar.gz: a35ff75d0e23174c3f5968b8115ac957ae687d0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1f67ad380e9b3869542722a7c33ab5ab6c0e6129cddd154b3be14b26087e6c094d71167b23df7bb5bb150b000f873e0d8e500204b804bc456a3c9cb3c7cb05c
|
7
|
+
data.tar.gz: 6ea6f508801838b752e8455b26d18fb1b83f88c846539a4d12eec27f584beae4f335c68197df5e88402593e48278eed3540966b2996d6e1befb18c77fc37635d
|
data/lib/clitopic/commands.rb
CHANGED
@@ -60,6 +60,7 @@ module Clitopic
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
|
63
64
|
def all_commands
|
64
65
|
cmds = []
|
65
66
|
Topics.topics.each do |k,topic|
|
@@ -77,6 +78,7 @@ module Clitopic
|
|
77
78
|
|
78
79
|
def prepare_run(cmd, arguments)
|
79
80
|
@current_options, @current_args = cmd.parse(arguments.dup)
|
81
|
+
return @current_options, @current_args
|
80
82
|
rescue OptionParser::ParseError => e
|
81
83
|
$stderr.puts Clitopic::Helpers.format_with_bang(e.message)
|
82
84
|
cmd.options = {}
|
@@ -54,17 +54,35 @@ module Clitopic
|
|
54
54
|
parser.to_s
|
55
55
|
end
|
56
56
|
|
57
|
+
def check_required (opts)
|
58
|
+
opts.each do |opt|
|
59
|
+
if opt[:required] == true
|
60
|
+
if options[opt[:name]].nil?
|
61
|
+
message = "Missing required option: #{opt[:args][0]}"
|
62
|
+
$stderr.puts(Clitopic::Helpers.format_with_bang(message) + "\n\n")
|
63
|
+
Clitopic::Commands.run(self.fullname, ["--help"])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def check_all_required
|
70
|
+
check_required(self.cmd_options)
|
71
|
+
check_required(self.topic.topic_options)
|
72
|
+
check_required(Clitopic::Commands.global_options)
|
73
|
+
end
|
74
|
+
|
57
75
|
def parse(args)
|
58
76
|
@invalid_options ||= []
|
59
77
|
parser.parse!(args)
|
78
|
+
check_all_required
|
60
79
|
@arguments = args
|
61
80
|
Clitopic::Commands.validate_arguments!(@invalid_options)
|
62
81
|
return @options, @arguments
|
63
|
-
rescue OptionParser::InvalidOption
|
82
|
+
rescue OptionParser::InvalidOption => ex
|
64
83
|
@invalid_options << ex.args.first
|
65
84
|
retry
|
66
85
|
end
|
67
|
-
|
68
86
|
end
|
69
87
|
end
|
70
88
|
end
|
data/lib/clitopic/version.rb
CHANGED