Method: InspecPlugins::Compliance::API::Login::ComplianceServer.compliance_verify_thor_options

Defined in:
lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb

.compliance_verify_thor_options(o) ⇒ Object

Compliance login requires ‘–user` or `–refresh_token` If `–user` then either `–password`, `–token`, or `–refresh-token`, is required

Raises:

  • (ArgumentError)


173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb', line 173

def self.compliance_verify_thor_options(o)
  error_msg = []

  error_msg.push('Please specify a server using `inspec compliance login https://SERVER`') if o['server'].nil?

  if o['user'].nil? && o['refresh_token'].nil?
    error_msg.push('Please specify a `--user=\'USER\'` or a `--refresh-token=\'TOKEN\'`')
  end

  if o['user'] && o['password'].nil? && o['token'].nil? && o['refresh_token'].nil?
    error_msg.push('Please specify either a `--password`, `--token`, or `--refresh-token`')
  end

  raise ArgumentError, error_msg.join("\n") unless error_msg.empty?
end