Skip to content

Commit 823f858

Browse files
bbelderbosclaude
andauthored
Support downloading premium exercises with API key (#2)
* feat: add API key support to exercise downloader Read PYBITES_API_KEY env var and send X-API-Key header when set. Without it, only free exercises are downloaded. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: add API key instructions to README Explain how to set PYBITES_API_KEY for downloading all premium exercises. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: extract write_all_exercises and auth_status_message for testability Pull the exercise-writing loop and auth status message out of main() into standalone functions that can be unit tested. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: add tempfile and serde_json dev dependencies for unit tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * update gitignore with default exercises dir created running it locally * refactor: restore essential comments and move println into write_all_exercises Restore two comments removed during refactoring that explain *why* (--test flag purpose, backup rationale for solved exercises). Move per-exercise println into write_all_exercises for consistency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7a583c0 commit 823f858

5 files changed

Lines changed: 372 additions & 41 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ target
2323
### custom section ###
2424

2525
notes/
26+
exercises

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@ Exercise downloader for https://rustplatform.com/
1010
cargo install --git https://github.com/markgreene74/pybites_rust.git
1111
```
1212
- `cd` to the directory where you want to save the exercises
13-
- run the downloader
13+
- run the downloader (free exercises only):
1414
```shell
1515
pybites-rust-download
1616
```
17+
- to download **all** exercises (requires premium), set your API key:
18+
```shell
19+
PYBITES_API_KEY=your-api-key-here pybites-rust-download
20+
```
21+
Or export it in your shell profile so you don't have to pass it every time:
22+
```shell
23+
export PYBITES_API_KEY=your-api-key-here
24+
```
25+
You can find your API key on your [profile page](https://rustplatform.com/profile/).
1726
1827
### Compile it manually
1928

exercise_downloader/Cargo.lock

Lines changed: 17 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exercise_downloader/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ serde = { version = "1.0.227", features = ["derive"] }
1010
[[bin]]
1111
name = "pybites-rust-download"
1212
path = "src/main.rs"
13+
14+
[dev-dependencies]
15+
serde_json = "1.0.149"
16+
tempfile = "3.25.0"

0 commit comments

Comments
 (0)