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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69133ceab5e2dd9f9b2c2951f950ce3e747e25b6
4
- data.tar.gz: b4b3dd0561e6a1b903b2d1c14a1420353a14bba3
3
+ metadata.gz: d33cb99755097e7f69ff49226238d5c488c61d70
4
+ data.tar.gz: a35ff75d0e23174c3f5968b8115ac957ae687d0f
5
5
  SHA512:
6
- metadata.gz: 99223e53b380536a589bb9f3752a43db56f3ce4ec46d070afaa1729438713a85ac897a83400e35cc813ee8046b0b4d8c23e74dc74ba38c4765d4b40cf07d77db
7
- data.tar.gz: 83e6817b3568220fb3da79972aee428f0c689a0009c1cc2019405d6ed3d117162b0d09ce12d664c57b037418b5f6923181aa863607e378f6bbb77ebb37c6db40
6
+ metadata.gz: e1f67ad380e9b3869542722a7c33ab5ab6c0e6129cddd154b3be14b26087e6c094d71167b23df7bb5bb150b000f873e0d8e500204b804bc456a3c9cb3c7cb05c
7
+ data.tar.gz: 6ea6f508801838b752e8455b26d18fb1b83f88c846539a4d12eec27f584beae4f335c68197df5e88402593e48278eed3540966b2996d6e1befb18c77fc37635d
@@ -115,7 +115,6 @@ module Clitopic
115
115
  load_options(topic_opts)
116
116
 
117
117
  if cmd_defaults.nil?
118
- puts "no defaults"
119
118
  return
120
119
  end
121
120
 
@@ -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 => ex
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
@@ -1,3 +1,3 @@
1
1
  module Clitopic
2
- VERSION = '0.9.7'
2
+ VERSION = '0.9.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli-topic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antoine Legrand