Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: Fix misleading message for unrecognised --exercise value #31

Closed
ee7 opened this issue Oct 10, 2020 · 0 comments · Fixed by #366
Closed

sync: Fix misleading message for unrecognised --exercise value #31

ee7 opened this issue Oct 10, 2020 · 0 comments · Fixed by #366
Assignees
Labels
cmd: sync kind: bug User-facing incorrect behavior

Comments

@ee7
Copy link
Member

ee7 commented Oct 10, 2020

Example

Give --exercise a value that doesn't exist, such as via a typo:

configlet sync --exercise bobb

Or spell it correctly on a track that doesn't implement it:

configlet sync --exercise bob

Current behaviour

The program outputs something like:

All exercises are synced!

Expected behaviour

We should probably show something like:

Error: 'bobb' is not a recognised exercise on the foo track
@ee7 ee7 self-assigned this Oct 21, 2020
@ee7 ee7 changed the title CLI: Add an error for unrecognised --exercise value sync: Fix misleading message for unrecognised --exercise value May 9, 2021
@ee7 ee7 added cmd: sync kind: bug User-facing incorrect behavior labels May 9, 2021
ee7 referenced this issue in ee7/exercism-configlet Nov 6, 2021
Summary:
- Pass slugs to the main proc for docs and metadata, rather than using
  `findExercises`. With this commit, we now only parse the track
  config.json into a `JsonNode` when we are syncing tests. Later, we
  might update the tests syncing to use jsony too.
- Fix a bug: previously `configlet sync -e foo` would claim that the
  `foo` exercise is up to date, even if it didn't exist on the track.

Fixes: #31
@ee7 ee7 closed this as completed in #366 Dec 15, 2021
ee7 added a commit that referenced this issue Dec 15, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd: sync kind: bug User-facing incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant