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|
"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('-v','--version','Show the current version of this gem')do
option_parser.on('-v',
'--version',
'Show the current version of this gem')do
puts"annotate v#{Annotate.version}"
puts"annotate v#{Annotate.version}"
@options[:exit]=true
@options[:exit]=true
end
end
option_parser.on('-m','--show-migration','Include the migration version number in the annotation')do
option_parser.on('-m',
'--show-migration',
'Include the migration version number in the annotation')do
env['include_version']='yes'
env['include_version']='yes'
end
end
option_parser.on('-k','--show-foreign-keys',
option_parser.on('-k',
'--show-foreign-keys',
"List the table's foreign key constraints in the annotation")do
"List the table's foreign key constraints in the annotation")do
env['show_foreign_keys']='yes'
env['show_foreign_keys']='yes'
end
end
option_parser.on('--ck',
option_parser.on('--ck',
'--complete-foreign-keys','Complete foreign key names in the annotation')do
'--complete-foreign-keys',
'Complete foreign key names in the annotation')do
env['show_foreign_keys']='yes'
env['show_foreign_keys']='yes'
env['show_complete_foreign_keys']='yes'
env['show_complete_foreign_keys']='yes'
end
end
option_parser.on('-i','--show-indexes',
option_parser.on('-i',
'--show-indexes',
"List the table's database indexes in the annotation")do
"List the table's database indexes in the annotation")do
env['show_indexes']='yes'
env['show_indexes']='yes'
end
end
option_parser.on('-s','--simple-indexes',
option_parser.on('-s',
'--simple-indexes',
"Concat the column's related indexes in the annotation")do
"Concat the column's related indexes in the annotation")do
env['simple_indexes']='yes'
env['simple_indexes']='yes'
end
end
...
@@ -168,84 +209,95 @@ module Annotate
...
@@ -168,84 +209,95 @@ module Annotate
end
end
option_parser.on('--ignore-model-subdirects',
option_parser.on('--ignore-model-subdirects',
"Ignore subdirectories of the models directory")do|_dir|
"Ignore subdirectories of the models directory")do
env['ignore_model_sub_dir']='yes'
env['ignore_model_sub_dir']='yes'
end
end
option_parser.on('--sort',
option_parser.on('--sort',
"Sort columns alphabetically, rather than in creation order")do|_dir|
"Sort columns alphabetically, rather than in creation order")do
env['sort']='yes'
env['sort']='yes'
end
end
option_parser.on('--classified-sort',
option_parser.on('--classified-sort',
"Sort columns alphabetically, but first goes id, then the rest columns, then the timestamp columns and then the association columns")do|_dir|
"Sort columns alphabetically, but first goes id, then the rest columns, then the timestamp columns and then the association columns")do
env['classified_sort']='yes'
env['classified_sort']='yes'
end
end
option_parser.on('-R','--require path',
option_parser.on('-R',
'--require path',
"Additional file to require before loading models, may be used multiple times")do|path|
"Additional file to require before loading models, may be used multiple times")do|path|
env['require']=ifenv['require'].present?
env['require']=ifenv['require'].present?
env['require']+",#{path}"
"#{env['require']},#{path}"
else
else
path
path
end
end
end
end
option_parser.on('-e','--exclude [tests,fixtures,factories,serializers]',Array,"Do not annotate fixtures, test files, factories, and/or serializers")do|exclusions|
option_parser.on('-f','--format [bare|rdoc|yard|markdown]',FORMAT_TYPES,'Render Schema Infomation as plain/RDoc/Yard/Markdown')do|fmt|
option_parser.on('-f',
env["format_#{fmt}"]='yes'
'--format [bare|rdoc|yard|markdown]',
FORMAT_TYPES,
'Render Schema Infomation as plain/RDoc/Yard/Markdown')do|format_type|
env["format_#{format_type}"]='yes'
end
end
option_parser.on('--force','Force new annotations even if there are no changes.')do|_force|
option_parser.on('--force',
'Force new annotations even if there are no changes.')do
env['force']='yes'
env['force']='yes'
end
end
option_parser.on('--frozen','Do not allow to change annotations. Exits non-zero if there are going to be changes to files.')do
option_parser.on('--frozen',
'Do not allow to change annotations. Exits non-zero if there are going to be changes to files.')do
env['frozen']='yes'
env['frozen']='yes'
end
end
option_parser.on('--timestamp','Include timestamp in (routes) annotation')do
option_parser.on('--timestamp',
'Include timestamp in (routes) annotation')do
env['timestamp']='true'
env['timestamp']='true'
end
end
option_parser.on('--trace','If unable to annotate a file, print the full stack trace, not just the exception message.')do|_value|
option_parser.on('--trace',
'If unable to annotate a file, print the full stack trace, not just the exception message.')do
env['trace']='yes'
env['trace']='yes'
end
end
option_parser.on('-I','--ignore-columns REGEX',"don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`")do|regex|
option_parser.on('-I',
'--ignore-columns REGEX',
"don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`")do|regex|
env['ignore_columns']=regex
env['ignore_columns']=regex
end
end
option_parser.on('--ignore-routes REGEX',"don't annotate routes that match a given REGEX (i.e., `annotate -I '(mobile|resque|pghero)'`")do|regex|
option_parser.on('--ignore-routes REGEX',
"don't annotate routes that match a given REGEX (i.e., `annotate -I '(mobile|resque|pghero)'`")do|regex|
env['ignore_routes']=regex
env['ignore_routes']=regex
end
end
option_parser.on('--hide-limit-column-types VALUES',"don't show limit for given column types, separated by commas (i.e., `integer,boolean,text`)")do|values|
"don't show limit for given column types, separated by commas (i.e., `integer,boolean,text`)")do|values|
env['hide_limit_column_types']=values.to_s
env['hide_limit_column_types']=values.to_s
end
end
option_parser.on('--hide-default-column-types VALUES',"don't show default for given column types, separated by commas (i.e., `json,jsonb,hstore`)")do|values|