File tree Expand file tree Collapse file tree 3 files changed +8
-5
lines changed
Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,7 @@ require 'optparse'
1313
1414# By default show user's reservations if no arguments are supplied
1515options = { action : 'list_reservations' }
16-
17- options . merge! Argonaut ::Settings . read_config [ 'options' ]
16+ options . merge! Argonaut ::Settings . config [ :options ]
1817
1918begin
2019 OptionParser . new do |opts |
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ class Gateway
77
88 attr_reader :api_token
99 attr_reader :url_root
10+ ERROR_MESSAGE = 'Could not load settings file ~/.argonaut.yml' . freeze
1011
1112 # Initializes the HTTP gateway to connect to argonaut's API endpoint
1213 # The consumer of this API can supply an API token and
@@ -43,12 +44,15 @@ def config
4344 }
4445
4546 if ENV [ 'ARGONAUT_API_TOKEN' ] . nil?
46- raise Argonaut ::Exceptions ::InvalidConfigurationError . new 'Could not get API token required to connect to Argonaut'
47+ raise Argonaut ::Exceptions ::InvalidConfigurationError . new ERROR_MESSAGE
4748 end
4849
4950 if ENV [ 'ARGONAUT_URL_ROOT' ] . nil?
50- raise Argonaut ::Exceptions ::InvalidConfigurationError . new 'Could not get Argonaut URL root'
51+ raise Argonaut ::Exceptions ::InvalidConfigurationError . new ERROR_MESSAGE
5152 end
53+ rescue Argonaut ::Exceptions ::InvalidConfigurationError => ice
54+ puts ice . message
55+ exit ( 2 )
5256 end
5357
5458 def url_from_path ( path )
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ def self.config
77 private_class_method
88
99 def self . read_config
10- YAML . load_file ( "#{ Dir . home } /.argonaut.yml" )
10+ YAML . load_file ( "#{ Dir . home } /.argonaut.yml" ) . with_indifferent_access
1111 rescue
1212 { options : {
1313 colorize_rows : true ,
You can’t perform that action at this time.
0 commit comments