lib/papertrail/cli_add_group.rb in papertrail-0.10.4 vs lib/papertrail/cli_add_group.rb in papertrail-0.11.0
- old
+ new
@@ -44,18 +44,18 @@
options.merge!(configfile_options)
end
raise OptionParser::MissingArgument, 'group' if options[:group].nil?
- connection = Papertrail::Connection.new(options)
+ Papertrail::Connection.new(options).start do |connection|
+ # Bail if group already exists
+ if connection.show_group(options[:group])
+ exit 0
+ end
- # Bail if group already exists
- if connection.show_group(options[:group])
- exit 0
- end
-
- if connection.create_group(options[:group], options[:wildcard])
- exit 0
+ if connection.create_group(options[:group], options[:wildcard])
+ exit 0
+ end
end
exit 1
rescue OptionParser::ParseError => e
puts "Error: #{e}"