-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-branch.sh
executable file
·115 lines (80 loc) · 2.62 KB
/
new-branch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#! /bin/bash
# for debug mode, set $execute to anything other than "true"
execute=true
BEVY_VERSION="0.13.2"
# usage: ./new-branch.sh path/to/example "Example Name"
# e.g. ./new-branch.sh 2d/2d_gizmos "2D Gizmos"
echo "moving to new branch: $1"
if [[ "${execute}" == "true" ]]; then
git -c advice.detachedHead=false checkout 52a42a9
git switch -c $1
fi
N_BRANCH=$(git branch -r | wc -l | sed 's/ //g')
N_BRANCH=$((N_BRANCH + 1))
read -d '' cargo_toml << EOF
[package]
name = "daily_bevy"
version = "0.1.0"
edition = "2021"
[dependencies]
bevy = "$BEVY_VERSION"
EOF
if [[ "${execute}" == "true" ]]; then
echo "$cargo_toml" > Cargo.toml
else
echo "----- Cargo.toml -----"
echo "$cargo_toml"
echo "----------------------"
fi
read -d '' main_rs << EOF
// source: https://github.com/bevyengine/bevy/blob/v$BEVY_VERSION/examples/$1.rs
use bevy::prelude::*;
fn main() {
App::new().add_systems(Update, hello_world_system).run();
}
fn hello_world_system() {
println!("hello world");
}
EOF
if [[ "${execute}" == "true" ]]; then
mkdir src
echo "$main_rs" > src/main.rs
else
echo "----- src/main.rs -----"
echo "$main_rs"
echo "-----------------------"
fi
read -d '' readme << EOF
# daily-bevy
Learn [Bevy](https://bevyengine.org/) by exploring a small example (almost) every day.
[Bevy](https://github.com/bevyengine/bevy/) is a free, open-source, cross-platform (Windows, macOS, Linux, Web, iOS, Android) game engine written in [Rust](https://www.rust-lang.org/).
This README shows entry #$N_BRANCH in this series. All other entries can be found at [daily-bevy/branches](https://github.com/awwsmm/daily-bevy/branches).
## $2
Today is day #$N_BRANCH of Daily Bevy.
This kata uses [Bevy \`v$BEVY_VERSION\`](https://github.com/bevyengine/bevy/tree/v$BEVY_VERSION).
### Today's Kata
...
#### The Code
Here's the \`main.rs\` for this example
\`\`\`rust
...
\`\`\`
And here's the \`Cargo.toml\` for this example
\`\`\`toml
[dependencies]
bevy = "$BEVY_VERSION"
\`\`\`
#### Discussion
...
## Learn More
If you found this first kata interesting, head over to [daily-bevy/branches](https://github.com/awwsmm/daily-bevy/branches) to see the rest of them.
If you have questions, comments, or corrections, please head over to [daily-bevy/discussions](https://github.com/awwsmm/daily-bevy/discussions) to join the conversation.
If you like what you've read above, you can [follow me on Bluesky](https://bsky.app/profile/awwsmm.bsky.social) or [Mastodon](https://mas.to/@awwsmm).
EOF
if [[ "${execute}" == "true" ]]; then
echo "$readme" > README.md
else
echo "------ README.md ------"
echo "$readme"
echo "-----------------------"
fi