Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchantey committed Sep 30, 2024
1 parent 448cf03 commit e7f8632
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
9 changes: 9 additions & 0 deletions crates/forky_bevy/src/extensions/vec3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ pub impl Vec3 {
}

/// Random position inside a unit cube (0, 1)
fn random_in_cube_signed() -> Self {
let mut rng = rand::thread_rng();
Vec3::new(
rng.gen_range(-1.0..1.0),
rng.gen_range(-1.0..1.0),
rng.gen_range(-1.0..1.0),
)
}

fn random_in_cube() -> Self {
let mut rng = rand::thread_rng();

Expand Down
16 changes: 11 additions & 5 deletions crates/forky_fs/src/cli/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ use clap::ArgMatches;
use clap::Command;
use std::io;

/// A helper for splitting [`clap::Command`] into subcommands, allowing
/// for modular composition.
pub trait Subcommand {
fn name(&self) -> &'static str;
fn about(&self) -> &'static str;
fn version(&self) -> &'static str { "0.0.1" }
/// Add your arguments here
fn append_command(&self, command: Command) -> Command { command }

/// Usually only used internally Internal use only
fn create_command(&self) -> Command {
let mut cmd = Command::new(self.name())
.about(self.about())
Expand All @@ -35,20 +39,20 @@ pub trait Subcommand {
let args = self
.create_command()
.get_matches_from(args.split_whitespace());
self.run_subs_or_default(&args)
self.run_subcommand_or_default(&args)
}

fn run_with_cli_args(&self) -> Result<()> {
let args = self.create_command().get_matches();
self.run_subs_or_default(&args)
self.run_subcommand_or_default(&args)
}
fn run_subs_or_default(&self, args: &ArgMatches) -> Result<()> {
fn run_subcommand_or_default(&self, args: &ArgMatches) -> Result<()> {
let mut sub_match = false;
for (name, args) in args.subcommand().iter() {
for sub in self.subcommands().iter() {
if sub.name() == *name {
sub_match = true;
sub.run_subs_or_default(args)?;
sub.run_subcommand_or_default(args)?;
}
}
}
Expand All @@ -73,7 +77,9 @@ pub trait Subcommand {
Err(anyhow!("No default function or subcommand entered.."))
}

fn run_loop(&self) -> Result<()> {

/// Run in a repl loop, reading from stdin.
fn run_repl(&self) -> Result<()> {
let stdin = io::stdin(); // We get `Stdin` here.
loop {
let mut input = String::new();
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions crates/forky_fs/src/utility/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod async_utils;
#[allow(unused_imports)]
pub use self::async_utils::*;
pub mod cli_args;
pub mod fs;
pub mod fs_async_utils;
#[allow(unused_imports)]
pub use self::fs_async_utils::*;
pub mod process;
pub mod terminal;

0 comments on commit e7f8632

Please sign in to comment.