lib/gitlab/cli_helpers.rb in gitlab-4.11.0 vs lib/gitlab/cli_helpers.rb in gitlab-4.12.0
- old
+ new
@@ -37,25 +37,26 @@
# Returns filtered required fields.
#
# @return [Array]
def required_fields(args)
- if args.any? && args.last.is_a?(String) && args.last.start_with?('--only=')
- args.last.gsub('--only=', '').split(',')
- else
- []
- end
+ filtered_fields(args, '--only=')
end
# Returns filtered excluded fields.
#
# @return [Array]
def excluded_fields(args)
- if args.any? && args.last.is_a?(String) && args.last.start_with?('--except=')
- args.last.gsub('--except=', '').split(',')
- else
- []
- end
+ filtered_fields(args, '--except=')
+ end
+
+ # Returns fields filtered by a keyword.
+ #
+ # @return [Array]
+ def filtered_fields(args, key)
+ return [] unless args.any? && args.last.is_a?(String) && args.last.start_with?(key)
+
+ args.last.gsub(key, '').split(',')
end
# Confirms command is valid.
#
# @return [Boolean]