bin/ridgepole in ridgepole-1.0.0 vs bin/ridgepole in ridgepole-1.0.1
- old
+ new
@@ -72,109 +72,107 @@
migrated
end
ARGV.options do |opt|
- begin
- opt.on('-c', '--config CONF_OR_FILE') { |v| config = v }
- opt.on('-E', '--env ENVIRONMENT') { |v| env = v }
- opt.on('-s', '--spec-name SPEC_NAME') { |v| spec_name = v }
- opt.on('-a', '--apply') { set_mode[:apply] }
- opt.on('-m', '--merge') do
- set_mode[:apply]
- options[:merge] = true
+ opt.on('-c', '--config CONF_OR_FILE') { |v| config = v }
+ opt.on('-E', '--env ENVIRONMENT') { |v| env = v }
+ opt.on('-s', '--spec-name SPEC_NAME') { |v| spec_name = v }
+ opt.on('-a', '--apply') { set_mode[:apply] }
+ opt.on('-m', '--merge') do
+ set_mode[:apply]
+ options[:merge] = true
+ end
+ opt.on('-f', '--file SCHEMAFILE') { |v| file = v }
+ opt.on('', '--dry-run') { options[:dry_run] = true }
+ opt.on('', '--table-options OPTIONS') { |v| options[:table_options] = v }
+ opt.on('', '--table-hash-options OPTIONS') do |v|
+ # NOTE: Ruby2.4 doesn't support `symbolize_names: true`
+ hash = YAML.safe_load(v).deep_symbolize_keys
+
+ case hash[:id]
+ when String
+ hash[:id] = hash[:id].to_sym
+ when Hash
+ hash[:id][:type] = hash[:id][:type].to_sym if hash[:id][:type]
end
- opt.on('-f', '--file SCHEMAFILE') { |v| file = v }
- opt.on('', '--dry-run') { options[:dry_run] = true }
- opt.on('', '--table-options OPTIONS') { |v| options[:table_options] = v }
- opt.on('', '--table-hash-options OPTIONS') do |v|
- # NOTE: Ruby2.4 doesn't support `symbolize_names: true`
- hash = YAML.safe_load(v).deep_symbolize_keys
- case hash[:id]
- when String
- hash[:id] = hash[:id].to_sym
- when Hash
- hash[:id][:type] = hash[:id][:type].to_sym if hash[:id][:type]
- end
+ options[:table_hash_options] = hash
+ end
+ opt.on('', '--alter-extra ALTER_SPEC') { |v| options[:alter_extra] = v }
+ opt.on('', '--external-script SCRIPT') { |v| options[:external_script] = v }
+ opt.on('', '--bulk-change') do
+ raise OptionParser::InvalidOption, 'Cannot use `bulk-change` in `merge`' if options[:merge]
- options[:table_hash_options] = hash
- end
- opt.on('', '--alter-extra ALTER_SPEC') { |v| options[:alter_extra] = v }
- opt.on('', '--external-script SCRIPT') { |v| options[:external_script] = v }
- opt.on('', '--bulk-change') do
- raise OptionParser::InvalidOption, 'Cannot use `bulk-change` in `merge`' if options[:merge]
+ options[:bulk_change] = true
+ end
- options[:bulk_change] = true
+ COLUMN_TYPES.each do |column_type, column_type_alias|
+ opt.on('', "--default-#{column_type_alias}-limit LIMIT", Integer) do |v|
+ options[:"default_#{column_type}_limit"] = v
end
+ end
- COLUMN_TYPES.each do |column_type, column_type_alias|
- opt.on('', "--default-#{column_type_alias}-limit LIMIT", Integer) do |v|
- options[:"default_#{column_type}_limit"] = v
- end
- end
+ opt.on('', '--pre-query QUERY') { |v| options[:pre_query] = v }
+ opt.on('', '--post-query QUERY') { |v| options[:post_query] = v }
+ opt.on('-e', '--export') { set_mode[:export] }
+ opt.on('', '--split') { split = true }
+ opt.on('', '--split-with-dir') { split = :with_dir }
+ opt.on('-d', '--diff DSL1 DSL2') do |diff_arg1|
+ set_mode[:diff]
+ diff_arg2 = ARGV.first
- opt.on('', '--pre-query QUERY') { |v| options[:pre_query] = v }
- opt.on('', '--post-query QUERY') { |v| options[:post_query] = v }
- opt.on('-e', '--export') { set_mode[:export] }
- opt.on('', '--split') { split = true }
- opt.on('', '--split-with-dir') { split = :with_dir }
- opt.on('-d', '--diff DSL1 DSL2') do |diff_arg1|
- set_mode[:diff]
- diff_arg2 = ARGV.first
-
- if [diff_arg1, diff_arg2].any? { |i| i.nil? || i.start_with?('-') }
- puts opt.help
- exit 1
- end
-
- ARGV.shift
- diff_files = [diff_arg1, diff_arg2]
+ if [diff_arg1, diff_arg2].any? { |i| i.nil? || i.start_with?('-') }
+ puts opt.help
+ exit 1
end
- opt.on('', '--with-apply') { diff_with_apply = true }
- opt.on('-o', '--output SCHEMAFILE') { |v| output_file = v }
- opt.on('-t', '--tables TABLES', Array) { |v| options[:tables] = v }
- opt.on('', '--ignore-tables REGEX_LIST', Array) { |v| options[:ignore_tables] = v.map { |i| Regexp.new(i) } }
- opt.on('', '--dump-without-table-options') { options[:dump_without_table_options] = true }
- opt.on('', '--dump-with-default-fk-name') { options[:dump_with_default_fk_name] = true }
- opt.on('', '--index-removed-drop-column') { options[:index_removed_drop_column] = true }
- opt.on('', '--drop-table') { options[:force_drop_table] = true }
- opt.on('', '--mysql-change-table-options') { options[:mysql_change_table_options] = true }
- opt.on('', '--mysql-change-table-comment') { options[:mysql_change_table_comment] = true }
- opt.on('', '--check-relation-type DEF_PK') { |v| options[:check_relation_type] = v }
- opt.on('', '--ignore-table-comment') { options[:ignore_table_comment] = true }
- opt.on('', '--skip-column-comment-change') { options[:skip_column_comment_change] = true }
- opt.on('', '--allow-pk-change') { options[:allow_pk_change] = true }
- opt.on('', '--create-table-with-index') { options[:create_table_with_index] = true }
- opt.on('', '--mysql-dump-auto-increment') do
- options[:mysql_dump_auto_increment] = true
- end
+ ARGV.shift
+ diff_files = [diff_arg1, diff_arg2]
+ end
+ opt.on('', '--with-apply') { diff_with_apply = true }
+ opt.on('-o', '--output SCHEMAFILE') { |v| output_file = v }
+ opt.on('-t', '--tables TABLES', Array) { |v| options[:tables] = v }
+ opt.on('', '--ignore-tables REGEX_LIST', Array) { |v| options[:ignore_tables] = v.map { |i| Regexp.new(i) } }
+ opt.on('', '--dump-without-table-options') { options[:dump_without_table_options] = true }
+ opt.on('', '--dump-with-default-fk-name') { options[:dump_with_default_fk_name] = true }
+ opt.on('', '--index-removed-drop-column') { options[:index_removed_drop_column] = true }
+ opt.on('', '--drop-table') { options[:force_drop_table] = true }
+ opt.on('', '--mysql-change-table-options') { options[:mysql_change_table_options] = true }
+ opt.on('', '--mysql-change-table-comment') { options[:mysql_change_table_comment] = true }
+ opt.on('', '--check-relation-type DEF_PK') { |v| options[:check_relation_type] = v }
+ opt.on('', '--ignore-table-comment') { options[:ignore_table_comment] = true }
+ opt.on('', '--skip-column-comment-change') { options[:skip_column_comment_change] = true }
+ opt.on('', '--allow-pk-change') { options[:allow_pk_change] = true }
+ opt.on('', '--create-table-with-index') { options[:create_table_with_index] = true }
- opt.on('-r', '--require LIBS', Array) { |v| v.each { |i| require i } }
- opt.on('', '--log-file LOG_FILE') { |v| options[:log_file] = v }
- opt.on('', '--verbose') { Ridgepole::Logger.verbose = true }
- opt.on('', '--debug') { options[:debug] = true }
- opt.on('', '--[no-]color') { |v| options[:color] = v }
+ opt.on('', '--mysql-dump-auto-increment') do
+ options[:mysql_dump_auto_increment] = true
+ end
- opt.on('-v', '--version') do
- puts opt.ver
- exit
- end
+ opt.on('-r', '--require LIBS', Array) { |v| v.each { |i| require i } }
+ opt.on('', '--log-file LOG_FILE') { |v| options[:log_file] = v }
+ opt.on('', '--verbose') { Ridgepole::Logger.verbose = true }
+ opt.on('', '--debug') { options[:debug] = true }
+ opt.on('', '--[no-]color') { |v| options[:color] = v }
- opt.parse!
+ opt.on('-v', '--version') do
+ puts opt.ver
+ exit
+ end
- if !mode || (%i[apply export].include?(mode) && !config) || (options[:with_apply] && !config)
- puts opt.help
- exit 1
- end
- rescue StandardError => e
- warn("[ERROR] #{e.message}")
+ opt.parse!
- puts "\t" + e.backtrace.join("\n\t") unless e.is_a?(OptionParser::ParseError)
-
+ if !mode || (%i[apply export].include?(mode) && !config) || (options[:with_apply] && !config)
+ puts opt.help
exit 1
end
+rescue StandardError => e
+ warn("[ERROR] #{e.message}")
+
+ puts "\t" + e.backtrace.join("\n\t") unless e.is_a?(OptionParser::ParseError)
+
+ exit 1
end
begin
logger = Ridgepole::Logger.instance
logger.debug = options[:debug]