- _is_json = false
- end
- if !_is_json
- # if resource_body is not valid JSON, it should be a filename (or '-' for stdin)
- if resource_body == '-'
- _resource_body_file = $stdin
+ resource_body_is_json = false
+ end
+ resource_body_is_readable_file = false
+ # if resource_body is not valid JSON, it should be a filename (or '-' for stdin)
+ if resource_body == '-'
+ resource_body_is_readable_file = true
+ resource_body_file = $stdin
+ elsif File.readable? resource_body
+ resource_body_is_readable_file = true
+ resource_body_file = File.open(resource_body, 'r')
+ end
+ if resource_body_is_json and resource_body_is_readable_file
+ abort "Argument specified for option '--#{resource_schema.to_sym}' is both valid JSON and a readable file. Please consider renaming the file: '#{resource_body}'"
+ elsif !resource_body_is_json and !resource_body_is_readable_file
+ if File.exists? resource_body
+ # specified file exists but is not readable
+ abort "Argument specified for option '--#{resource_schema.to_sym}' is an existing file but is not readable. Please check permissions on: '#{resource_body}'"