Skip to content

Commit

Permalink
Improve exercise generator (#1797)
Browse files Browse the repository at this point in the history
- Add a clap-based CLI
  All user-input can now be entered upfront with cli flags
  or later by being prompted for it interactively.

- Limit output of rustfmt passed onto user
  (There are usually many duplicates when generating test cases.)

- Handle absence of canonical data
  (e.g. for custom exercises) not from problem-specifications)

piggyback:

- Make exercise difficulty in track config type-safe
  • Loading branch information
senekor authored Nov 23, 2023
1 parent b2f72ef commit ff92b1c
Show file tree
Hide file tree
Showing 15 changed files with 487 additions and 267 deletions.
4 changes: 2 additions & 2 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Please familiarize yourself with the [Exercism documentation about practice exer

[Exercism documentation about practice exercises]: https://exercism.org/docs/building/tracks/practice-exercises

Run `just add-practice-exercise` and you'll be prompted for the minimal
Run `just add-exercise` and you'll be prompted for the minimal
information required to generate the exercise stub for you.
After that, jump in the generated exercise and fill in any todos you find.
This includes most notably:
Expand Down Expand Up @@ -89,7 +89,7 @@ This includes their test suite and user-facing documentation.
Before proposing changes here,
check if they should be made `problem-specifications` instead.

Run `just update-practice-exercise` to update an exercise.
Run `just update-exercise` to update an exercise.
This outsources most work to `configlet sync --update`
and runs the test generator again.

Expand Down
13 changes: 4 additions & 9 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ test:
cd rust-tooling && cargo test
# TODO format exercises

add-practice-exercise:
cd rust-tooling && cargo run --quiet --bin generate_exercise
add-exercise *args="":
cd rust-tooling/generate; cargo run --quiet --release -- add {{ args }}

update-practice-exercise:
cd rust-tooling && cargo run --quiet --bin generate_exercise update

# TODO remove. resets result of add-practice-exercise.
clean:
git restore config.json exercises/practice
git clean -- exercises/practice
update-exercise *args="":
cd rust-tooling/generate; cargo run --quiet --release -- update {{ args }}
127 changes: 126 additions & 1 deletion rust-tooling/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust-tooling/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
members = ["generator", "ci-tests", "utils", "models"]
members = ["generate", "ci-tests", "utils", "models"]
resolver = "2"
18 changes: 0 additions & 18 deletions rust-tooling/ci-tests/tests/difficulties.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "generator"
name = "generate"
version = "0.1.0"
edition = "2021"
description = "Generates exercise boilerplate, especially test cases"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.4.8", features = ["derive"] }
convert_case = "0.6.0"
glob = "0.3.1"
inquire = "0.6.2"
Expand Down
Loading

0 comments on commit ff92b1c

Please sign in to comment.