diff --git a/src/service.cr b/src/service.cr index ba87c6f..7837e8b 100644 --- a/src/service.cr +++ b/src/service.cr @@ -49,24 +49,25 @@ begin if args[0] == "help" puts parser elsif args[0] == "add" - environment : String? = nil providers = Hash(String, String).new + environment, service = Service.parse_id args[1] + + args.shift args.each_with_index do |arg, i| next if i == 0 match = arg.match /(.*)=(.*)/ if match.nil? - # FIXME: Check environment is not defined already. - environment = arg + raise ::Service::Exception.new "usage: service add " next end providers[match[1]] = match[2] end - Service.new(args[1], environment).tap do |service| + Service.new(service, environment).tap do |service| service.consumes.each do |token| provider = providers[token.token]?