bin/mvclient in mvclient-0.0.3 vs bin/mvclient in mvclient-0.0.4

- old
+ new

@@ -128,22 +128,23 @@ user_id = nil if $options[:user] =~ USER_ID_REGEX user_id = $options[:user] else users = $client.search_for_user($options[:user]) - if users.empty? - puts "User '#{$options[:user]}' not found" - exit(1) - elsif users.size > 1 + if users.size > 1 # check for an exact match among the search results matching_users = users.select { |user| user['fullName'] == $options[:user] } - if matching_users.size > 1 + if matching_users.size != 1 puts "Multiple users match '#{$options[:user]}'; please be more specific." puts "Try one of #{users.map{|user| "'#{user['fullName']}'"}.join(', ')}" exit(1) else users = matching_users end + end + if users.empty? + puts "User '#{$options[:user]}' not found" + exit(1) end user_id = users[0]['id'] end response = $client.send_appreciation! user_id, amount: $options[:amount], note: $options[:note], company_value_id: value_id, private: $options[:private]