Skip to content

Commit

Permalink
Refactor: Change Action to bool check (exercism#89)
Browse files Browse the repository at this point in the history
The option for using the check-only mode is `--check`, rather than
`--action=check` so let's reflect that internally.
  • Loading branch information
ee7 authored Oct 29, 2020
1 parent 8730d06 commit 17902af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
7 changes: 3 additions & 4 deletions src/canonical_data_syncer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
9 changes: 3 additions & 6 deletions src/cli.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -16,8 +13,8 @@ type
verDetailed = "detailed"

Conf* = object
action*: Action
exercise*: Option[string]
check*: bool
mode*: Mode
verbosity*: Verbosity
probSpecsDir*: Option[string]
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 17902af

Please sign in to comment.