feat(watch): show hint while watching
`rustlings hint ...` command is not convenient when doing exercises with `rustlings watch`.
This PR makes it possible for user to type `hint` while running `watch` and get hint text for exercise which is currently failing.
e.g.
```rust
...
--> exercises/variables/variables1.rs:13:36
|
13 | println!("x has the value {}", x);
| ^ not found in this scope
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0425`.
type 'hint' to get help:
hint
Hint: The declaration on line 12 is missing a keyword that is needed in Rust
to create a new variable binding.
```
Update line numbers in hints and outdated comment
In functions4, the missing code is in line 14 in the latest version:
```rust
error: expected type, found `{`
--> exercises/functions/functions4.rs:14:30
|
14 | fn sale_price(price: i32) -> {
| ^ expected type
error: aborting due to previous error
```
but the hint points to line 12. This is due to a recent change in 2cdd61294f.
Also includes similar updates for strings2 and primitive_types4.
fix(run): makes `run` never prompt
`watch` and `verify` do prompt the user to actively move to the
next exercise. This change fixes `run` to never prompt. Previously
it was inconsistent between "test" and "compile" exercises.
BREAKING CHANGE: we again change the behavior of the `run` command
`watch` and `verify` do prompt the user to actively move to the
next exercise. This change fixes `run` to never prompt. Previously
it was inconsistent between "test" and "compile" exercises.
BREAKING CHANGE: we again change the behavior of the `run` command
feat(cli): check for rustc before doing anything
Addresses #190. From the backtraces shown there, it seems like we're not able to launch `rustc` (which is odd, given that they probably compiled and installed `rustlings` 🤷♀️)
Refactor hints
Breaking change. This removes hints from the end of files, and puts them into `info.toml`. You can now access hints using:
```
rustlings hint <exerciseName>
```
ALSO this changes the exercise system to index by name for `run` and `hint`, so:
```
rustlings run exercises/if/if1.rs
```
becomes
```
rustlings run if1
```
Changes the execution mode for `watch`, asking for user input
We've [observed](https://hackmd.io/-cK6aPhnTwiCiI7u6k0xug?both) that learners can get confused when they do get everything right, but they _still_ get errors... which come from the next exercise, no the one they just edited.
This PR changes it so they have to confirm they want to move forward by removing the `I AM NOT DONE` comment.
![Screenshot at 2019-11-11 15:13:39](https://user-images.githubusercontent.com/1636604/68593566-0abd3900-0496-11ea-9e9d-6c43b91bf21d.png)
* [ ] The particular string is of course subject to bikeshed.
### Alternatives/doubts
* The coolest solution I could imagine would involve a proc-macro attribute `#![ready(false)]` that they could edit once they're done, but it's a bit complicated to set up.
* For now I've put `I AM NOT DONE` everywhere, I think it's what make more sense.
Hints are now accessible using the CLI subcommand `rustlings hint
<exercise name`.
BREAKING CHANGE: This fundamentally changes the way people interact with exercises.
BREAKING CHANGE: This changes the way you use `rustlings run` by now
requiring an abridged form of the previous filename, e.g:
`rustlings run exercises/if/if1.rs` becomes
`rustlings run if1`
feat: Add enums exercises
Creates an exhaustive list of enum exercises. This goes through the basics of different ways to derive enums with mixed data type variants, as well as the use of the all important `match` operator.
watch: clears terminal before entering loop
Fixes#146
If someone is sliding in and out of "watch" mode, it can make it hard
to tell which error messages are still relevant. This patch resolves
that by clearing the terminal entirely before entering watch's loop.
Note that the escape character is chosen for compatibility reasons, because different shells/terminals can change which commands they accept or have installed, betting on what other commands are in use to collect data seems risky, and just expecting them to implement ANSI escape code sequences is more reliable. This seems especially true since Windows is seeking more UNIX compatibility in its terminals going forward, even though it doesn't implement the POSIX standard per se.
If someone is sliding in and out of "watch" mode, it can make it hard
to tell which error messages are still relevant. This patch resolves
that by clearing the terminal entirely before entering watch's loop.
chore: Clarify comment in exercises/test1.rs
closes#194
The author of issue #194 suggests that the wording of the comment is at
least ambiguous about the desired results. I believe this change more
clearly describes the expectation of the exercise.
closes#194
The author of issue #194 suggests that the wording of the comment is at
least ambiguous about the desired results. I believe this change more
clearly describes the expectation of the exercise.