Skip to content

Commit 7af41a4

Browse files
committed
refactor(cli): extract --out handling into method to satisfy RuboCop
1 parent ae1f722 commit 7af41a4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/skunk/cli/options/argv.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ def parse
2323
self.mode = :compare_branches
2424
end
2525

26-
opts.on("-o", "--out console,json,html", Array, "Output formats or file") do |values|
27-
if values.all? { |val| Skunk::Config.supported_format?(val.to_sym) }
28-
Skunk::Config.formats = values.map(&:to_sym)
29-
else
30-
self.output_filename = values.join(",")
31-
end
32-
end
26+
opts.on("-o", "--out console,json,html", Array, "Output formats or file") { |values| parse_out_option(values) }
3327

3428
opts.on_tail("-v", "--version", "Show gem's version") do
3529
self.mode = :version
@@ -44,6 +38,16 @@ def parse
4438
def to_h
4539
super.merge(output_filename: output_filename)
4640
end
41+
42+
private
43+
44+
def parse_out_option(values)
45+
if values.all? { |val| Skunk::Config.supported_format?(val.to_sym) }
46+
Skunk::Config.formats = values.map(&:to_sym)
47+
else
48+
self.output_filename = values.join(",")
49+
end
50+
end
4751
end
4852
end
4953
end

0 commit comments

Comments
 (0)