Skip to content

Commit

Permalink
Feature: Add --trackDir option
Browse files Browse the repository at this point in the history
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: exercism#50
  • Loading branch information
ee7 committed Oct 30, 2020
1 parent 2ebc4f6 commit 5d7f540
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Options:
-v, --verbosity <verbosity> The verbosity of output. Allowed values: q[uiet], n[ormal], d[etailed]
-p, --prob-specs-dir <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 <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
```
Expand Down
6 changes: 6 additions & 0 deletions src/cli.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type
verbosity*: Verbosity
probSpecsDir*: string
offline*: bool
trackDir*: string

Opt = enum
optExercise = "exercise"
Expand All @@ -27,6 +28,7 @@ type
optVerbosity = "verbosity"
optProbSpecsDir = "probSpecsDir"
optOffline = "offline"
optTrackDir = "trackDir"
optHelp = "help"
optVersion = "version"

Expand Down Expand Up @@ -95,6 +97,7 @@ Options:
{list(optVerbosity)} <verbosity> The verbosity of output. {allowedValues(Verbosity)}
{list(optProbSpecsDir)} <dir> 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)} <dir> 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"""

Expand Down Expand Up @@ -124,6 +127,7 @@ proc initConf: Conf =
verbosity: verNormal,
probSpecsDir: "",
offline: false,
trackDir: "",
)

func normalizeOption(s: string): string =
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion src/tracks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 5d7f540

Please sign in to comment.