Skip to content

Commit f2c02d0

Browse files
committed
Add show_check_constraints option to Options and Parser
1 parent a779627 commit f2c02d0

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

lib/annotate_rb/options.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def from(options = {}, state = {})
4545
ignore_unknown_models: false, # ModelAnnotator
4646
include_version: false, # ModelAnnotator
4747
show_complete_foreign_keys: false, # ModelAnnotator
48+
show_check_constraints: false, # ModelAnnotator
4849
show_foreign_keys: true, # ModelAnnotator
4950
show_indexes: true, # ModelAnnotator
5051
simple_indexes: false, # ModelAnnotator
@@ -109,6 +110,7 @@ def from(options = {}, state = {})
109110
:ignore_model_sub_dir,
110111
:ignore_unknown_models,
111112
:include_version,
113+
:show_check_constraints,
112114
:show_complete_foreign_keys,
113115
:show_foreign_keys,
114116
:show_indexes,

lib/annotate_rb/parser.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ def add_model_options_to_parser(option_parser)
198198
@options[:simple_indexes] = true
199199
end
200200

201+
option_parser.on("-c",
202+
"--show-check-constraints",
203+
"List the table's check constraints in the annotation") do
204+
@options[:show_check_constraints] = true
205+
end
206+
201207
option_parser.on("--hide-limit-column-types VALUES",
202208
"don't show limit for given column types, separated by commas (i.e., `integer,boolean,text`)") do |values|
203209
@options[:hide_limit_column_types] = values.to_s

spec/lib/annotate_rb/parser_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ module AnnotateRb # rubocop:disable Metrics/ModuleLength
295295
end
296296
end
297297

298+
%w[-c --show-check-constraints].each do |option|
299+
describe option do
300+
let(:args) { [option] }
301+
302+
it "sets show_check_constraints to true" do
303+
expect(result).to include(show_check_constraints: true)
304+
end
305+
end
306+
end
307+
298308
describe "--model-dir" do
299309
let(:option) { "--model-dir" }
300310
let(:set_value) { "some_dir/" }

0 commit comments

Comments
 (0)