-
- if File.exists?(args[0])
- begin
- content = File.read(args[0])
- PSON::load(content) || args[1]
- rescue Exception => e
- if args[1]
- args[1]
+ require 'open-uri'
+ begin
+ if args[0].start_with?('http://', 'https://')
+ username = ''
+ password = ''
+ if (match = args[0].match(%r{(http\://|https\://)(.*):(.*)@(.*)}))
+ # If URL is in the format of https://username:password@example.local/my_hash.yaml
+ protocol, username, password, path = match.captures
+ url = "#{protocol}#{path}"
+ elsif (match = args[0].match(%r{(http\:\/\/|https\:\/\/)(.*)@(.*)}))
+ # If URL is in the format of https://username@example.local/my_hash.yaml
+ protocol, username, path = match.captures
+ url = "#{protocol}#{path}"