From 5d7f5400454f7516fdf5793cdd7186d93031285d Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Fri, 23 Oct 2020 16:40:01 +0200 Subject: [PATCH] Feature: Add `--trackDir` option With this commit, we can now establish a beginning state by specifying: - a track directory - a problem-specifications directory - the offline mode This allows us to do black-box testing of the release binary, running something like: canonical_data_syncer -t /tmp/python -p /tmp/my_prob_specs --offline and then asserting that the changes made are as expected. Closes: #50 --- README.md | 1 + src/cli.nim | 6 ++++++ src/tracks.nim | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ec0e23fbf..7e0576e85 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Options: -v, --verbosity The verbosity of output. Allowed values: q[uiet], n[ormal], d[etailed] -p, --prob-specs-dir Use this `problem-specifications` directory, rather than cloning temporarily -o, --offline Do not check that the directory specified by `-p, --prob-specs-dir` is up-to-date + -t, --track-dir Specify a track directory to use instead of the current directory -h, --help Show this help message and exit --version Show this tool's version information and exit ``` diff --git a/src/cli.nim b/src/cli.nim index 72ca3b386..f15458603 100644 --- a/src/cli.nim +++ b/src/cli.nim @@ -19,6 +19,7 @@ type verbosity*: Verbosity probSpecsDir*: string offline*: bool + trackDir*: string Opt = enum optExercise = "exercise" @@ -27,6 +28,7 @@ type optVerbosity = "verbosity" optProbSpecsDir = "probSpecsDir" optOffline = "offline" + optTrackDir = "trackDir" optHelp = "help" optVersion = "version" @@ -95,6 +97,7 @@ Options: {list(optVerbosity)} The verbosity of output. {allowedValues(Verbosity)} {list(optProbSpecsDir)} Use this `problem-specifications` directory, rather than cloning temporarily {list(optOffline)} Do not check that the directory specified by `{list(optProbSpecsDir)}` is up-to-date + {list(optTrackDir)} Specify a track directory to use instead of the current directory {list(optHelp)} Show this help message and exit {list(optVersion)} Show this tool's version information and exit""" @@ -124,6 +127,7 @@ proc initConf: Conf = verbosity: verNormal, probSpecsDir: "", offline: false, + trackDir: "", ) func normalizeOption(s: string): string = @@ -196,6 +200,8 @@ proc processCmdLine*: Conf = result.probSpecsDir = val of optOffline: result.offline = true + of optTrackDir: + result.trackDir = val of optHelp: showHelp() of optVersion: diff --git a/src/tracks.nim b/src/tracks.nim index af55b85de..539ed875b 100644 --- a/src/tracks.nim +++ b/src/tracks.nim @@ -83,5 +83,9 @@ proc findTrackExercises(repo: TrackRepo, conf: Conf): seq[TrackExercise] = result.add(newTrackExercise(repoExercise)) proc findTrackExercises*(conf: Conf): seq[TrackExercise] = - let trackRepo = newTrackRepo() + let trackRepo = + if conf.trackDir.len > 0: + TrackRepo(dir: conf.trackDir) + else: + newTrackRepo() trackRepo.findTrackExercises(conf)