Skip to content

Commit

Permalink
Provide a fill_template script (#77)
Browse files Browse the repository at this point in the history
Hi.

I think this template project is a wonderful idea to play around with
egui for ealuationa nd eventually starting something real with it.

But I found it kind of cumbersome to fill in the template consistently
over all the files, so I wrote this little script I would like to share,
in case it is deemed useful.
  • Loading branch information
markusdd authored Jun 26, 2024
1 parent 6ec4bd5 commit 00ff8b2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can compile your app natively or for the web, and share it using Github Page

Start by clicking "Use this template" at https://github.com/emilk/eframe_template/ or follow [these instructions](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template).

Change the name of the crate: Chose a good name for your project, and change the name to it in:
Change the name of the crate: Choose a good name for your project, and change the name to it in:
* `Cargo.toml`
* Change the `package.name` from `eframe_template` to `your_crate`.
* Change the `package.authors`
Expand All @@ -25,6 +25,9 @@ Change the name of the crate: Chose a good name for your project, and change the
* Change the `'./eframe_template.js'` to `./your_crate.js` (in `filesToCache` array)
* Change the `'./eframe_template_bg.wasm'` to `./your_crate_bg.wasm` (in `filesToCache` array)

Alternatively, you can run `fill_template.sh` which will ask for the needed names and email and perform the above patches for you. This is particulary useful if you clone this repository outside GitHub and hence cannot make use of its
templating function.

### Learning about egui

`src/app.rs` contains a simple example app. This is just to give some inspiration - most of it can be removed if you like.
Expand Down
27 changes: 27 additions & 0 deletions fill_template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env sh

set -e

echo "To fill the template tell me your egui project crate name: "

read crate

echo "To fill the template tell me your name (for author in Cargo.toml): "

read name

echo "To fill the template tell me your e-mail address (also for Cargo.toml): "

read email

echo "Patching files..."

sed -i "s/eframe_template/$crate/g" Cargo.toml
sed -i "s/eframe_template/$crate/g" src/main.rs
sed -i "s/eframe template/$crate/g" index.html
sed -i "s/eframe_template/$crate/g" assets/sw.js
sed -i "s/Emil Ernerfeldt/$name/g" Cargo.toml
sed -i "s/[email protected]/$email/g" Cargo.toml

echo "Done."

0 comments on commit 00ff8b2

Please sign in to comment.