Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add a --no-readme flag to time command #57

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

Closed
tguichaoua wants to merge 1 commit into fspoettel:main from tguichaoua:time-no-readme
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Solutions for [Advent of Code](https://adventofcode.com/) in [Rust](https://www.

This template supports all major OS (macOS, Linux, Windows).

### 📝 Create your repository
### 📝 Create your repository

1. Open [the template repository](https://github.com/fspoettel/advent-of-code-rust) on Github.
2. Click [Use this template](https://github.com/fspoettel/advent-of-code-rust/generate) and create your repository.
Expand Down Expand Up @@ -56,7 +56,7 @@ Every [solution](https://github.com/fspoettel/advent-of-code-rust/blob/main/src/

### ➡️ Download input for a day

> [!IMPORTANT]
> [!IMPORTANT]
> This requires [installing the aoc-cli crate](#configure-aoc-cli-integration).

You can automatically download puzzle input and description by either appending the `--download` flag to `scaffold` (e.g. `cargo scaffold 4 --download`) or with the separate `download` command:
Expand Down Expand Up @@ -126,6 +126,8 @@ By default, this command checks for missing benchmarks, runs those solutions, an

Please note that these are not _scientific_ benchmarks, understand them as a fun approximation. 😉 Timings, especially in the microseconds range, might change a bit between invocations.

To compute the times but not update the benchmarks table in the readme, use the `--no-readme` flag.

### ➡️ Run all tests

```sh
Expand Down Expand Up @@ -156,9 +158,9 @@ cargo read <day>

During december, the `today` shorthand command can be used to:

- scaffold a solution for the current day
- download its input
- and read the puzzle
- scaffold a solution for the current day
- download its input
- and read the puzzle

in one go.

Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mod args {
},
Time {
all: bool,
no_readme: bool,
day: Option<Day>,
},
#[cfg(feature = "today")]
Expand All @@ -50,9 +51,11 @@ mod args {
},
Some("time") => {
let all = args.contains("--all");
let no_readme = args.contains("--no-readme");

AppArguments::Time {
all,
no_readme,
day: args.opt_free_from_str()?,
}
}
Expand Down Expand Up @@ -102,7 +105,11 @@ fn main() {
}
Ok(args) => match args {
AppArguments::All { release, time } => all::handle(release, time),
AppArguments::Time { day, all } => time::handle(day, all),
AppArguments::Time {
day,
all,
no_readme,
} => time::handle(day, all, !no_readme),
AppArguments::Download { day } => download::handle(day),
AppArguments::Read { day } => read::handle(day),
AppArguments::Scaffold { day, download } => {
Expand Down
18 changes: 10 additions & 8 deletions src/template/commands/time.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::template::run_multi::run_multi;
use crate::template::timings::Timings;
use crate::template::{all_days, readme_benchmarks, Day};

pub fn handle(day: Option<Day>, recreate_all: bool) {
pub fn handle(day: Option<Day>, recreate_all: bool, update_readme: bool) {
let stored_timings = Timings::read_from_file();

let days_to_run = day.map_or_else(
Expand All @@ -26,13 +26,15 @@ pub fn handle(day: Option<Day>, recreate_all: bool) {
let merged_timings = stored_timings.merge(&timings);
merged_timings.store_file().unwrap();

println!();
match readme_benchmarks::update(merged_timings) {
Ok(()) => {
println!("Stored updated benchmarks.");
}
Err(_) => {
eprintln!("Failed to store updated benchmarks.");
if update_readme {
println!();
match readme_benchmarks::update(merged_timings) {
Ok(()) => {
println!("Stored updated benchmarks.");
}
Err(_) => {
eprintln!("Failed to store updated benchmarks.");
}
}
}
}

AltStyle によって変換されたページ (->オリジナル) /