From 470e41cb7b18a3b3c647a6afb0670eea52c90943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fn=20=E2=8C=83=20=E2=8C=A5?= <70830482+FnControlOption@users.noreply.github.com> Date: Sun, 31 Oct 2021 22:23:14 -0700 Subject: [PATCH] Raise error if attempting to both explain issue and autocorrect --- src/ameba/cli/cmd.cr | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ameba/cli/cmd.cr b/src/ameba/cli/cmd.cr index 42238e30..0e62027b 100644 --- a/src/ameba/cli/cmd.cr +++ b/src/ameba/cli/cmd.cr @@ -7,8 +7,15 @@ module Ameba::Cli def run(args = ARGV) 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.autocorrect = opts.autocorrect? + config.autocorrect = autocorrect if globs = opts.globs config.globs = globs @@ -26,8 +33,8 @@ module Ameba::Cli runner = Ameba.run(config) - if location = opts.location_to_explain - runner.explain(location) + if location_to_explain + runner.explain(location_to_explain) else exit 1 unless runner.success? end