Skip to content

Commit

Permalink
feat: support --version
Browse files Browse the repository at this point in the history
  • Loading branch information
ndavd committed Dec 27, 2023
1 parent 47112ee commit 1d49632
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ use resources::{
};
use std::collections::HashMap;

fn version_info() -> String {
format!("{} v{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"))
}

fn main() {
if let Some(arg) = std::env::args().nth(1) {
if arg.as_str() == "--version" {
println!("{}", version_info());
return;
}
}

App::new()
.add_plugins(DefaultPlugins.build().set(WindowPlugin {
primary_window: Some(Window {
Expand Down
6 changes: 3 additions & 3 deletions src/text.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::resources::FontHandle;
use crate::version_info;
use crate::NCubeDimension;
use crate::NCubePlanesOfRotation;
use crate::NCubeRotations;
Expand Down Expand Up @@ -52,9 +53,8 @@ fn spawn_title_text(mut commands: Commands, mut fonts: ResMut<Assets<Font>>) {
commands.spawn(TextBundle {
text: Text::from_section(
format!(
"{} v{} - {}\n{}",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
"{} - {}\n{}",
version_info(),
env!("CARGO_PKG_DESCRIPTION"),
env!("CARGO_PKG_AUTHORS"),
),
Expand Down

0 comments on commit 1d49632

Please sign in to comment.