From 17902affb6785f4416a60ec27bd8df1f0261e034 Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Thu, 29 Oct 2020 14:03:44 +0100 Subject: [PATCH] Refactor: Change `Action` to bool `check` (#89) The option for using the check-only mode is `--check`, rather than `--action=check` so let's reflect that internally. --- src/canonical_data_syncer.nim | 7 +++---- src/cli.nim | 9 +++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/canonical_data_syncer.nim b/src/canonical_data_syncer.nim index a52c240c..22dd1aba 100644 --- a/src/canonical_data_syncer.nim +++ b/src/canonical_data_syncer.nim @@ -9,10 +9,9 @@ proc main = setupLogging(conf) - case conf.action - of actSync: - sync(conf) - of actCheck: + if conf.check: check(conf) + else: + sync(conf) main() diff --git a/src/cli.nim b/src/cli.nim index 80eb77fd..c9ccd13c 100644 --- a/src/cli.nim +++ b/src/cli.nim @@ -2,9 +2,6 @@ import std/[options, os, strformat, strutils, terminal] import pkg/[cligen/parseopt3] type - Action* = enum - actSync, actCheck - Mode* = enum modeChoose = "choose" modeInclude = "include" @@ -16,8 +13,8 @@ type verDetailed = "detailed" Conf* = object - action*: Action exercise*: Option[string] + check*: bool mode*: Mode verbosity*: Verbosity probSpecsDir*: Option[string] @@ -110,8 +107,8 @@ proc prefix(kind: CmdLineKind): string = proc initConf: Conf = result = Conf( - action: actSync, exercise: none(string), + check: false, mode: modeChoose, verbosity: verNormal, probSpecsDir: none(string), @@ -179,7 +176,7 @@ proc processCmdLine*: Conf = of optExercise: result.exercise = some(val) of optCheck: - result.action = actCheck + result.check = true of optMode: result.mode = parseVal[Mode](kind, key, val) of optVerbosity: