Unverified Commit cad47f56 by Andrew W. Lee Committed by GitHub

Make --additional_file_patterns consistent by using dashes (#654)

Changed references to `--additional_file_patterns` to be `--additional-file-patterns` to make it consistent with other flags.
parent 05ee2167
...@@ -163,7 +163,7 @@ you can do so with a simple environment variable, instead of editing the ...@@ -163,7 +163,7 @@ you can do so with a simple environment variable, instead of editing the
== Options == Options
Usage: annotate [options] [model_file]* Usage: annotate [options] [model_file]*
--additional_file_patterns Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`) --additional-file-patterns Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)
-d, --delete Remove annotations from all model files or the routes.rb file -d, --delete Remove annotations from all model files or the routes.rb file
-p [before|top|after|bottom], Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s) -p [before|top|after|bottom], Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)
--position --position
...@@ -216,18 +216,18 @@ you can do so with a simple environment variable, instead of editing the ...@@ -216,18 +216,18 @@ you can do so with a simple environment variable, instead of editing the
--ignore-unknown-models don't display warnings for bad model files --ignore-unknown-models don't display warnings for bad model files
--with-comment include database comments in model annotations --with-comment include database comments in model annotations
=== Option: +additional_file_patterns+ === Option: +additional-file-patterns+
CLI: +--additional_file_patterns+<br> CLI: +--additional-file-patterns+<br>
Ruby: +:additional_file_patterns+ Ruby: +:additional-file-patterns+
Provide additional paths for the gem to annotate. These paths can include globs. Provide additional paths for the gem to annotate. These paths can include globs.
It is recommended to use absolute paths. Here are some examples: It is recommended to use absolute paths. Here are some examples:
- <code>/app/lib/decorates/%MODEL_NAME%/&ast;.rb</code> - <code>/app/lib/decorates/%MODEL_NAME%/*.rb</code>
- <code>/app/lib/forms/%PLURALIZED_MODEL_NAME%/&ast;&ast;/&ast;.rb</code> - <code>/app/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb</code>
- <code>/app/lib/forms/%TABLE_NAME%/&ast;.rb</code> - <code>/app/lib/forms/%TABLE_NAME%/*.rb</code>
The appropriate model will be inferred using the <code>%*%</code> syntax, annotating any matching files. The appropriate model will be inferred using the <code>%*%</code> syntax, annotating any matching files.
It works with existing filename resolutions (options for which can be found in the +resolve_filename+ method of It works with existing filename resolutions (options for which can be found in the +resolve_filename+ method of
......
...@@ -49,7 +49,7 @@ module Annotate ...@@ -49,7 +49,7 @@ module Annotate
option_parser.banner = 'Usage: annotate [options] [model_file]*' option_parser.banner = 'Usage: annotate [options] [model_file]*'
option_parser.on('--additional_file_patterns path1,path2,path3', Array, "Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)") do |additional_file_patterns| option_parser.on('--additional-file-patterns path1,path2,path3', Array, "Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)") do |additional_file_patterns|
ENV['additional_file_patterns'] = additional_file_patterns ENV['additional_file_patterns'] = additional_file_patterns
end end
...@@ -57,10 +57,6 @@ module Annotate ...@@ -57,10 +57,6 @@ module Annotate
@options[:target_action] = :remove_annotations @options[:target_action] = :remove_annotations
end end
option_parser.on('--additional_file_patterns path1,path2,path3', Array, "Additional file paths or globs to annotate") do |additional_file_patterns|
ENV['additional_file_patterns'] = additional_file_patterns
end
option_parser.on('-p', '--position [before|top|after|bottom]', positions, option_parser.on('-p', '--position [before|top|after|bottom]', positions,
'Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)') do |p| 'Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)') do |p|
env['position'] = p env['position'] = p
......
...@@ -14,13 +14,9 @@ module Annotate # rubocop:disable Metrics/ModuleLength ...@@ -14,13 +14,9 @@ module Annotate # rubocop:disable Metrics/ModuleLength
end end
end end
%w[--additional_file_patterns].each do |option| %w[--additional-file-patterns].each do |option|
describe option do describe option do
it 'sets array of paths to :additional_file_patterns' do it 'sets array of paths to :additional_file_patterns' do
# options = "-a ${('foo/bar' 'baz')}"
# Parser.parse(options)
# expect(ENV['additional_file_patterns']).to eq(['foo/bar', 'baz'])
paths = 'foo/bar,baz' paths = 'foo/bar,baz'
allow(ENV).to receive(:[]=) allow(ENV).to receive(:[]=)
Parser.parse([option, paths]) Parser.parse([option, paths])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment