Commit graph

180 commits

Author SHA1 Message Date
mo8it
87e55ccffd Use the parsed exercises instead of glob 2024-03-25 22:20:00 +01:00
mo8it
51712cc19f Merge get_sysroot_src into the constructor 2024-03-25 03:49:10 +01:00
mo8it
efa9f57048 Add anyhow 2024-03-25 03:46:56 +01:00
mo8it
e4520602f5 Use the NotFound variant of the IO error 2024-03-25 02:41:45 +01:00
mo8it
83cd91ccca Replace toml with toml_edit 2024-03-25 02:35:51 +01:00
mo8it
51b4c240ed Use which instead of running rustc --version 2024-03-25 00:30:01 +01:00
mo8it
f205ee3d4c Call looks_done only once 2024-03-24 18:50:46 +01:00
mo8it
e1375ef431 Use to_string_lossy 2024-03-24 18:47:27 +01:00
mo8it
a325df55d1 Cache filters 2024-03-23 21:56:40 +01:00
mo8it
27fa7c3e4a Move the const string to the bottom like others 2024-03-23 19:00:15 +01:00
mo8it
0d93266462 Initialize the input buffer with some capacity 2024-03-23 18:56:30 +01:00
mo8it
3dce7e5696 Improvements to watch mode 2024-03-23 18:51:25 +01:00
liv
7f530ebf20
Merge pull request #1783 from neuschaefer/fe-nish
Fe-nish line rendering improvements
2023-11-29 17:33:41 +01:00
J. Neuschäfer
12d1bf407a feat(watch): Add red color to the finishing ferris
This adds some eye-candy for users who finish Rustlings. It is based on
ANSI terminal escape sequences and should work in most environments.
2023-11-22 02:07:52 +01:00
J. Neuschäfer
5c4821ac6f fix(watch): Fix rendering of the finishing ferris
In commit 571bab2 ("Run clippy --fix"), the "" string was changed to
r"", even though it contains an intentional escape sequence, which now
looks wrong. My commit undoes this change:

Before:

	+----------------------------------------------------+
	|          You made it to the Fe-nish line!          |
	+--------------------------  ------------------------+
				  \\/
	     ▒▒          ▒▒▒▒▒▒▒▒      ▒▒▒▒▒▒▒▒          ▒▒
	   ▒▒▒▒  ▒▒    ▒▒        ▒▒  ▒▒        ▒▒    ▒▒  ▒▒▒▒
	   ▒▒▒▒  ▒▒  ▒▒            ▒▒            ▒▒  ▒▒  ▒▒▒▒
	 ░░▒▒▒▒░░▒▒  ▒▒            ▒▒            ▒▒  ▒▒░░▒▒▒▒
	   ▓▓▓▓▓▓▓▓  ▓▓      ▓▓██  ▓▓  ▓▓██      ▓▓  ▓▓▓▓▓▓▓▓
	     ▒▒▒▒    ▒▒      ████  ▒▒  ████      ▒▒░░  ▒▒▒▒
	       ▒▒  ▒▒▒▒▒▒        ▒▒▒▒▒▒        ▒▒▒▒▒▒  ▒▒
		 ▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▒▒▓▓▒▒▒▒▒▒▒▒
		   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
		     ▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒
		   ▒▒  ▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒▒▒▒▒▒  ▒▒
		 ▒▒    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    ▒▒
	       ▒▒    ▒▒    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    ▒▒    ▒▒
	       ▒▒  ▒▒    ▒▒                  ▒▒    ▒▒  ▒▒
		   ▒▒  ▒▒                      ▒▒  ▒▒


After:

	+----------------------------------------------------+
	|          You made it to the Fe-nish line!          |
	+--------------------------  ------------------------+
				   \/
	     ▒▒          ▒▒▒▒▒▒▒▒      ▒▒▒▒▒▒▒▒          ▒▒
	   ▒▒▒▒  ▒▒    ▒▒        ▒▒  ▒▒        ▒▒    ▒▒  ▒▒▒▒
	   ▒▒▒▒  ▒▒  ▒▒            ▒▒            ▒▒  ▒▒  ▒▒▒▒
	 ░░▒▒▒▒░░▒▒  ▒▒            ▒▒            ▒▒  ▒▒░░▒▒▒▒
	   ▓▓▓▓▓▓▓▓  ▓▓      ▓▓██  ▓▓  ▓▓██      ▓▓  ▓▓▓▓▓▓▓▓
	     ▒▒▒▒    ▒▒      ████  ▒▒  ████      ▒▒░░  ▒▒▒▒
	       ▒▒  ▒▒▒▒▒▒        ▒▒▒▒▒▒        ▒▒▒▒▒▒  ▒▒
		 ▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▒▒▓▓▒▒▒▒▒▒▒▒
		   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
		     ▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒
		   ▒▒  ▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒▒▒▒▒▒  ▒▒
		 ▒▒    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    ▒▒
	       ▒▒    ▒▒    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    ▒▒    ▒▒
	       ▒▒  ▒▒    ▒▒                  ▒▒    ▒▒  ▒▒
		   ▒▒  ▒▒                      ▒▒  ▒▒

Running `cargo clippy` (version 0.1.70) after this commit does not
reveal any new warnings.

Fixes: 571bab2 ("Run clippy --fix")
2023-11-22 02:07:36 +01:00
Matthias Richter
adf7d1b975 chore(watch): update notify dependency to v6
closes #1640
2023-11-17 00:56:02 +01:00
danieltinazzi
3181d9f3f8 fix progress bar count 2023-11-04 17:29:10 +01:00
DocWilco
cc658eb288 fix(cli): make debugging in windows work
On windows, if `stderr` or `stdin` aren't also set to `Stdio::null()`
the `spawn()` fails with `The handle is invalid`, and `rustlings`
thinks that there's no `rustc` installed.
2023-09-27 21:33:49 +02:00
mo8it
5a93f2a4f1 Port to Clap 2023-09-04 13:30:46 +02:00
mo8it
571bab20c1 Run clippy --fix 2023-08-26 23:07:20 +02:00
liv
f2de12aa34 release: 5.5.1 2023-05-17 21:05:51 +02:00
liv
f452fd7bb0 release: 5.5.0 2023-05-17 16:30:22 +02:00
Romain Bayle
c44e3025f9 option success_hints added to the struct Watchargs instead of Args 2023-05-02 22:46:41 +02:00
Romain Bayle
5d3696a9e6 feat(cli): added success-hints option for the rustlings command
closes #1373
2023-05-01 03:04:06 +02:00
Sebastian LaVine
a4a5691a7b
feat: Add "!" command to rustlings watch 2023-04-16 21:44:08 -04:00
Alexandre ESSE
d7111cb4a3 fix(main.rs): remove trailing spaces 2023-03-31 11:58:15 +02:00
liv
7f1754ecc5 release: 5.4.1 2023-03-10 17:39:59 +01:00
liv
fc9fb536ca release: 5.4.0 2023-02-12 18:01:48 +01:00
TenzinRabgy
8e36256eac chore(watch): decrease watch delay
closes #1215
2023-01-04 04:49:51 -05:00
Tobias Klauser
1b9d4bbf72
Fix typo in method name 2023-01-03 14:14:07 +01:00
liv
9ad884aadb chore: bump version 2022-12-23 16:55:42 +01:00
liv
587e2d6dcd
Merge pull request #1220 from azzamsa/percentage
feat(verify): add progress percentage in watch mode
2022-10-14 10:30:32 +01:00
azzamsa
68388e5d4f feat(verify): add progress percentage in watch mode 2022-10-14 05:28:49 +07:00
Yuri Astrakhan
2940ad059d Apply uninlined-format-args clippy lint
This lint should also be applied to the excersies,
but I am not certain how to run it for all non-crate individual files.

To re-run:

```
rustup run nightly cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2022-10-12 16:43:07 -04:00
mokou
c923e7af73 chore: release 5.2.1 2022-09-06 12:22:17 +02:00
mokou
3309a01b5e chore: release 5.2.0 2022-08-27 19:48:15 +01:00
magnusrodseth
d59dde320b chore: Add suggested changes 2022-08-18 12:47:26 +02:00
magnusrodseth
6f44cb1dd2 feat: Add reset command, given a filename 2022-08-17 16:31:53 +02:00
mokou
d0c7b06eff chore: release 5.1.1 2022-08-17 10:43:50 +02:00
mokou
714a8075cc chore: bump version 2022-08-16 09:54:25 +02:00
mokou
5435b80841 chore: bump version 2022-07-16 14:30:04 +02:00
mokou
6588d9be22 chore: bump version 2022-07-01 16:48:34 +02:00
Jack Clayton
be87cc9fa6 Add lsp command to fix rust-analyzer 2022-06-17 11:36:06 +08:00
Ryan Lowe
6fae5d6114
Merge branch 'main' into progress-indicator 2022-04-20 23:29:47 -04:00
mokou
9ec35d899c chore: bump version
Plus, remove the clog configuration file,
since that's not being used anymore.
2022-04-20 09:44:37 +02:00
mokou
cf9f382873 chore: bump version 2022-04-14 11:16:00 +02:00
Ryan Lowe
9be012dda0 feat!: Add progress indicator
closes #360

BREAKING CHANGE: verify() has a new function signature so it can
know the current completion progress
2022-02-05 16:54:11 -05:00
apogeeoak
c1f35e46df Merge branch 'main' into text 2022-02-04 19:27:42 -05:00
ana
d57c183028 release: 4.6.0 2021-09-25 11:23:05 +02:00
Antoine Busch
1caef0b434 feat: Add "quit" command to rustlings watch
closes: #842
2021-09-24 23:55:55 +10:00
ana
3352b5a4d3 chore: improve println! usage 2021-09-24 13:04:30 +02:00
ana
a7dc080b95 feat: add more watch commands
Includes:
- quit, to quit the shell instead of having to press Cmd/Ctrl-C or Cmd/Ctrl-D
- help, to display an overview of all the commands available in watch mode.

Closes #842.
2021-09-21 10:36:11 +02:00
Ben Armstead
1cd9328a58
fix(cli): remove unnecessary borrows (#829)
* Update dependencies

* Format better and remove unnecessary borrows
2021-08-24 14:06:30 +02:00
ana
ba087ce64a release: 4.5.0
Signed-off-by: ana <ana@ana.st>
2021-07-07 22:23:52 +02:00
Richthofen
d20e413a68
feat(cli): Add "next" to run the next unsolved exercise. (#785)
* Add "run next" to run the next unsolved exercise.

* Fix a grammar error in the message.

* Update README.md with the suggested change

Co-authored-by: marisa <mokou@fastmail.com>

* Update the README.md for "rustlings hint next".

Co-authored-by: marisa <mokou@fastmail.com>
2021-06-30 12:05:49 +02:00
apogeeoak
f78c480208 fix(cli): Move long text strings into constants. 2021-04-27 17:14:54 -04:00
mokou
84461c20cb release: 4.4.0 2021-04-24 11:57:00 +02:00
Zerotask
cf42ddc449
chore(watch): add hint for the exercises README.md
rustlings watch will now show an additional hint for the corresponding README.me
2021-04-23 20:28:55 +02:00
mokou
347f30bd86 fix(main): Let find_exercise work with borrows 2021-04-21 16:21:56 +02:00
mokou
7928122fce feat: Replace clap with argh
I’ve been wanting to do this for a while, but always procrastinated on it. We’ve been using Clap since the 2.0 rewrite, but Clap is known to be a fairly heavy library. Since Rustlings is usually peoples’ first contact with a Rust compilation, I think it’s in our best interests that this complation is as fast as possible. In effect, replacing Clap with the smaller, structopt-style `argh` reduces the amount of crates needing to be compiled from 82 to 60.

I also think this makes the code way easier to read, we don’t need to use Clap’s methods anymore, but can switch over to using pure Rust methods, e.g., switches are booleans, options are Option<String>s or the like, and subcommands are just structs.
2021-04-21 10:08:26 +02:00
Patrick Hintermayer
1c6f7e4b7b
feat(list): updated progress percentage 2021-04-19 09:39:05 +02:00
Zerotask
c0e3daacaf
feat(list): added progress info
Added a progress info at the bottom of the list for command: rustlings list

closes #705
2021-04-18 15:37:41 +02:00
Larry Garfield
91ee27f22b
fix: Spelling error 2021-02-24 15:03:26 -06:00
apogeeoak
2e84f34cf3 chore: Updated source to follow clippy suggestions. 2021-02-09 18:21:18 -05:00
Abdou Seck
8bbe4ff138 feat(cli): Improve the list command with options, and then some
1.
`rustlings list` should now display more than just the exercise names.
Information such as file paths and exercises statuses should be displayed.
The `--paths` option limits the displayed fields to only the path names; while the `--names`
option limits the displayed fields to only exercise names.
You can also control which exercises are displayed, by using the `--filter` option, or
the `--solved` or `--unsolved` flags.

Some use cases:
- Fetching pending exercise files with the keyword "conversion" to pass to my editor:
```sh
vim $(rustlings list --filter "conversion" --paths --unsolved)
```

- Fetching exercise names with keyword "conversion" to pass to `rustlings run`:
```sh
for exercise in $(rustlings list --filter "conversion" --names)
do
    rustlings run ${exercise}
done
```

2.
This should also fix #465, and will likely fix #585, as well.
That bug mentioned in those issues has to do with the way the `watch` command handler fetches the pending exercises.
Going forward, the least recently updated exercises along with all the other exercises in a pending state are fetched.
2021-01-08 13:21:00 -05:00
mokou
a303d508cf release: 4.3.0 2020-12-29 11:39:26 +01:00
Brock
fa9f522b7f
feat: Crab? (#586)
Crab?
2020-11-11 23:06:14 +01:00
Caleb Webber
838f9f3008
feat: add "rustlings list" command 2020-11-10 18:36:19 +01:00
Caleb Webber
d61b4e5a13
fix: log error output when inotify limit is exceeded
closes #472
2020-11-05 19:30:50 -05:00
Étienne Barrié
81f8c2f83c chore: Run cargo fmt 2020-08-10 10:42:54 -04:00
Adi Vaknin
4f2468e14f
feat(cli): Added 'cls' command to 'watch' mode (#474) 2020-07-23 20:23:27 +02:00
mokou
55a9284665 chore: Move from master branch to main branch 2020-06-14 14:48:51 +02:00
Abdou Seck
8ad5f9bf53 feat: Add a --nocapture option to display test harnesses' outputs
This new feature can be accessed by invoking rustlings with --nocapture.

Both unit and integration tests added.

closes #262

BREAKING CHANGES:
The following function take a new boolean argument:
	* `run`
	* `verify`
	* `test`
	* `compile_and_test`
2020-06-04 11:18:26 -04:00
Abdou Seck
02a2fe4871 Collapse nested if statements 2020-06-04 11:18:09 -04:00
Roberto Vidal
43dc31193a refactor: exercise evaluation
Exercise evaluation (compilation + execution) now uses Results
Success/failure messages are standardized
2020-02-20 20:27:05 +01:00
Kate Hart
d25ee55a32
feat: Show a completion message when watching
The completion message is shown only once all exercises succeed and are
not annotated with "I AM NOT DONE." The watch command will also exit

closes #251
2019-12-26 20:27:49 -08:00
vyaslav
8143d57b4e feat(watch): show hint while watching 2019-11-18 20:52:57 +01:00
Roberto Vidal
36a033b87a feat(cli): check for rustc before doing anything
Addresses #190.
2019-11-11 18:00:54 +01:00
marisa
1a7bb5a400 Address feedback 2019-11-11 17:47:45 +01:00
marisa
ec2d4bd3ee
Merge branch 'master' into refactor-hints 2019-11-11 17:21:06 +01:00
marisa
ce9fa6ebbf feat(hint): Add test for hint 2019-11-11 17:19:50 +01:00
marisa
9bdb0a12e4 feat: Refactor hint system
Hints are now accessible using the CLI subcommand `rustlings hint
<exercise name`.

BREAKING CHANGE: This fundamentally changes the way people interact with exercises.
2019-11-11 16:51:38 +01:00
Roberto Vidal
2cdd61294f feat: improve watch execution mode
The `watch` command now requires user action to move to the next
exercise.

BREAKING CHANGE: this changes the behavior of `watch`.
2019-11-11 16:23:35 +01:00
marisa
627cdc07d0 feat: Index exercises by name
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`
2019-11-11 15:46:32 +01:00
WofWca
3aff590855 improvement(watch): clear screen before each verify()
Closes #146
2019-11-09 22:24:24 +08:00
Jubilee Young
83be517e77 watch: clears terminal before entering loop
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.
2019-11-09 00:57:36 -08:00
Fredrik Jambrén
ba85ca32c4 Check if changed exercise file exists before calling verify. 2019-07-11 23:54:18 +02:00
Dan Wilhelm
f72e0ca979 chore: Remove missed highlighting char from Issue #133 2019-06-10 20:24:18 -07:00
liv
62696f5819 Remove highlighting and syntect 2019-06-05 12:18:50 +02:00
liv
7eddee6f7a add a slightly more helpful error message 2019-04-22 18:43:39 +08:00
Chris Pearce
8c867a001a Remove unwrap on canonicalize result 2019-04-12 22:24:13 +01:00
Chris Pearce
d01a71f7de Extract exercise struct to encapsulate path logic 2019-04-12 08:58:25 +01:00
Chris Pearce
0c7bd12372 Fix test failing due to panic 2019-04-07 20:13:04 +01:00
liv
022921168d fix watch command path execution 2019-03-27 10:58:56 +01:00
Kyle Isom
9fc4a83987 Be nicer when rustlings isn't run from the right directory.
Before, rustlings would panic if it wasn't in the right directory. It
took me a minute to figure out why, and this wasn't my first intro to
Rust. It would probably help new users if they saw a helpful message
instead of a stack trace.
2019-03-17 11:43:47 -07:00
Andrew Bagshaw
3b5dfac44e Remove unnessecary whitespace 2019-03-15 16:01:45 -07:00
Andrew Bagshaw
a6a8b61b12
Change to \n 2019-03-15 12:47:06 -07:00
Andrew Bagshaw
6cd42bb821 Add clear break between verify executions 2019-03-13 14:08:28 -07:00
Andrew Bagshaw
3f114cc069 Start verification at most recently modified file 2019-03-13 13:50:54 -07:00
lyn
abf175111d clippy-ify 2019-03-11 15:09:20 +01:00