-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync: handle docs, metadata, and filepaths (#366)
This commit adds important features to `configlet sync`. Before this commit, the `sync` command operated only on tests. For each Practice Exercise on the track that existed in the `exercism/problem-specifications` repo, `sync` would check or update the exercise's `.meta/tests.toml` file using the corresponding upstream `canonical-data.json` file. With this commit, the `sync` command still has that functionality (which can now be toggled with the `--tests` option). But for such Practice Exercises that come from `problem-specifications`, `sync` also gains these new options: - `--docs` to check or update each exercise's `.docs/instructions.md` (and possibly `.docs/introduction.md`) file, using the corresponding docs in `problem-specifications`. - `--metadata` to check or update the `blurb`, `source`, and `source_url` values in each exercise's `.meta/config.json` file, using those in the corresponding `metadata.toml` file in `problem-specifications`. And for both Concept Exercises and Practice Exercises, `sync` gains these new options: - `--filepaths` for populating empty or missing `files` values in an exercise `.meta/config.json` from the track `config.json` file. - `-y/--yes` to auto-confirm every prompt for updating docs, filepaths, and metadata. Note that the `-y/--yes` option does not affect prompts for updating tests. Before this commit, `sync` had a `--mode` option that allowed the user to specify whether they want to be prompted (the default) to include/exclude/skip each unseen test individually, or non-interactively include/exclude all of them. This commit replaces the `--mode` option: the user should now pass the mode value to the `--tests` option instead (for example, `--tests include`). The default is still `choose`. A plain `configlet sync` operates on the full syncing scope, and so does the same as `configlet sync --docs --filepaths --metadata --tests`. The `sync` command still operates on every exercise by default, and still does not create/alter the track's files unless the `-u/--update` option is used. When writing a `.meta/config.json` file, `sync` tries to maintain the key order that it saw, aiming to minimize noise in diffs and PRs. An exception is when the file is missing or lacks required keys, in which case configlet will create those files and keys. Therefore when adding a Practice Exercise `foo` that exists in `problem-specifications` to a track, to create the docs and a starter `.meta/config.json` file we can run: $ configlet sync -uy -e foo --docs --filepaths --metadata And to interactively create the `.meta/tests.toml` file: $ configlet sync -u -e foo --tests When updating exercise `.meta/config.json` files, configlet will preserve a top-level key named `custom` and its value of any valid JSON object. You can use this for track-specific feature flagging. `sync` still performs a `git clone` of `problem-specifications` by default. In the future, we intend for configlet to cache that repo - but to skip cloning in the meantime, please continue to use the `-o/--offline` and `-p/--prob-specs-dir` options. For example: $ configlet sync -o -p /path/to/local/problem-specifications For more details about the new `sync` functionality and more usage examples, please see the `README.md` file. We will soon add the `configlet fmt` command, for rewriting JSON files on a track in a canonical form without syncing. You may recall that the configlet for Exercism v2 had a `fmt` command with similar functionality. This commit also fixes a bad error message: previously `configlet sync -e foo` would say that the `foo` exercise is up to date, even if `foo` didn't exist on the track. Closes: #298 Closes: #179 Fixes: #31
- Loading branch information
Showing
22 changed files
with
2,614 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/parseopt3.nim b/parseopt3.nim | ||
index a865952..850d016 100644 | ||
--- a/parseopt3.nim | ||
+++ b/parseopt3.nim | ||
@@ -267,8 +267,17 @@ proc doLong(p: var OptParser) = | ||
p.kind = cmdError | ||
return | ||
if p.pos < p.cmd.len: # Take opt arg from next param | ||
- p.val = p.cmd[p.pos] | ||
- p.pos += 1 | ||
+ # If the next parameter begins with `-`, parse it as an option, even when | ||
+ # `longNoVal` is both non-empty and lacks the given long option. | ||
+ # This allows a long option `foo` to have an optional value, supporting both | ||
+ # of the below forms: | ||
+ # --foo val1 --bar val2 | ||
+ # --foo --bar val2 | ||
+ # Without the below line, `--bar` is parsed as the value of `--foo` in the | ||
+ # latter case. | ||
+ if not p.cmd[p.pos].startsWith("-"): | ||
+ p.val = p.cmd[p.pos] | ||
+ p.pos += 1 | ||
elif p.longNoVal.len != 0: | ||
p.val = "" | ||
p.pos += 1 |
Oops, something went wrong.