86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/releasehx/cli.rb', line 86
def default source_arg
setup_logger
ReleaseHx.logger.debug "Starting ReleaseHx with version/source: #{source_arg}"
load_and_configure_settings(ReleaseHx.attrs['app_default_config_path'])
if options[:debug]
begin
config_dump = SgymlHelpers.deep_stringify_safe(@settings).to_yaml
ReleaseHx.logger.debug "Operative config settings:\n#{config_dump}"
rescue StandardError => e
require 'pp' ReleaseHx.logger.debug "Rescued config PP dump:\n#{PP.pp(@settings, +'')}"
raise e
end
end
source_arg_type = version_or_file(source_arg)
if source_arg_type == :invalid
raise Thor::Error, <<~ERRTXT
ERROR: Invalid file extension for source file: #{source_arg}
Valid draft file types are: #{ReleaseHx.attrs['draft_source_file_types']}
Valid extensions are: #{ReleaseHx.attrs['draft_source_extensions']}
ERRTXT
end
ReleaseHx.logger.info "Source type: #{source_arg_type}"
if options[:verbose] && @settings['origin']
ReleaseHx.logger.debug "✓ Source configured: #{@settings['origin']['source']}"
end
if options[:check]
if source_arg_type == :file
raise Thor::Error,
'ERROR: Scan operations require a version number as the first argument.'
end
perform_scan(source_arg)
return
end
if options[:api_data] && (options[:api_data].nil? || options[:api_data].empty?)
raise Thor::Error, 'Must specify a PATH for --api-data. E.g. --api-data cached-1-1-1.json'
end
if options[:api_data] && !File.exist?(options[:api_data])
raise Thor::Error, "API data file not found: #{options[:api_data]}"
end
if options[:api_data]
ReleaseHx.logger.debug "✓ Using cached API data: #{options[:api_data]}"
elsif options[:fetch]
ReleaseHx.logger.info "✓ Will fetch fresh data from #{@settings['origin']['source']} API" if options[:verbose]
end
if options[:api_data] && options[:fetch]
ReleaseHx.logger.warn 'Warning: --fetch ignored when --api-data is specified'
end
if [options[:adoc], options[:md], options[:yaml]].compact.size > 1
raise Thor::Error, 'ERROR: Only one of --adoc, --md, or --yaml (or aliases) may be specified.'
end
if options[:append]
perform_append(source_arg)
return
end
determine_operations(source_arg)
end
|