hygen rust

This commit is contained in:
Niccolo Borgioli 2023-11-18 17:06:39 +01:00
parent 3af5af2461
commit eb723f5112
No known key found for this signature in database
GPG Key ID: D93C615F75EE4F0B
9 changed files with 35 additions and 6 deletions

View File

@ -2,4 +2,4 @@
> New days are generated with [`hygen`](https://github.com/jondot/hygen).
>
> `hygen riddle new --year 2021 --day 01`
> `bun run gen --year 2022 --day 1`

View File

@ -0,0 +1,10 @@
---
inject: true
to: cargo.toml
before: "# INJECT HERE"
skip_if: <%= id %>
---
[[bin]]
name = "<%= id %>"
path = "<%= dir %>/rust/main.rs"

View File

@ -12,6 +12,13 @@ async function getInput(year, day) {
module.exports = {
params: async ({ args }) => {
return { ...args, input: await getInput(args.year, args.day) }
const day = args.day.toString().padStart(2, '0') // Padded
return {
...args,
id: `${args.year}-${day}`,
dir: `./${args.year}/${day}`,
input: await getInput(args.year, parseInt(day)),
day,
}
},
}

View File

@ -1,5 +1,5 @@
---
to: <%= year %>/<%= day %>/input.txt
to: <%= dir %>/input.txt
unless_exists: true
---
<%= input %>

View File

@ -1,5 +1,5 @@
---
to: <%= year %>/<%= day %>/python/main.py
to: <%= dir %>/python/main.py
unless_exists: true
---
#!/usr/bin/env python

View File

@ -1,5 +1,5 @@
---
to: <%= year %>/<%= day %>/README.md
to: <%= dir %>/README.md
unless_exists: true
---

View File

@ -0,0 +1,9 @@
---
to: <%= dir %>/rust/main.rs
unless_exists: true
---
fn main() {
// Part A
let contents = include_str!("../test.txt").trim();
println!("A: {}", contents);
}

View File

@ -1,4 +1,4 @@
---
to: <%= year %>/<%= day %>/test.txt
to: <%= dir %>/test.txt
unless_exists: true
---

View File

@ -1,4 +1,7 @@
{
"scripts": {
"gen": "bun hygen riddle new"
},
"dependencies": {
"axios": "^1.6.0",
"hygen": "^6.2.11"