Raise error if attempting to both explain issue and autocorrect

This commit is contained in:
fn ⌃ ⌥ 2021-10-31 22:23:14 -07:00
parent a40fdee33f
commit 470e41cb7b
1 changed files with 10 additions and 3 deletions

View File

@ -7,8 +7,15 @@ module Ameba::Cli
def run(args = ARGV) def run(args = ARGV)
opts = parse_args args opts = parse_args args
location_to_explain = opts.location_to_explain
autocorrect = opts.autocorrect?
if location_to_explain && autocorrect
raise "Invalid usage: Cannot explain an issue and autocorrect at the same time."
end
config = Config.load opts.config, opts.colors? config = Config.load opts.config, opts.colors?
config.autocorrect = opts.autocorrect? config.autocorrect = autocorrect
if globs = opts.globs if globs = opts.globs
config.globs = globs config.globs = globs
@ -26,8 +33,8 @@ module Ameba::Cli
runner = Ameba.run(config) runner = Ameba.run(config)
if location = opts.location_to_explain if location_to_explain
runner.explain(location) runner.explain(location_to_explain)
else else
exit 1 unless runner.success? exit 1 unless runner.success?
end end