Skip to content

Commit cfa458e

Browse files
alphastrataFirestar99
authored andcommitted
fix: buff the help menu for the wgpu-runner
1 parent fcb4fdf commit cfa458e

File tree

1 file changed

+15
-3
lines changed
  • examples/runners/wgpu/src

1 file changed

+15
-3
lines changed

examples/runners/wgpu/src/lib.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
// #![allow()]
7373

7474
use clap::Parser;
75+
use clap::builder::PossibleValue;
76+
use clap::ValueEnum;
7577
use std::borrow::Cow;
7678
use strum::{Display, EnumString};
7779

@@ -81,14 +83,24 @@ mod compute;
8183

8284
mod graphics;
8385

84-
#[derive(EnumString, Display, PartialEq, Eq, Copy, Clone)]
86+
#[derive(Debug, EnumString, Display, PartialEq, Eq, Copy, Clone, ValueEnum)]
8587
pub enum RustGPUShader {
8688
Simplest,
8789
Sky,
8890
Compute,
8991
Mouse,
9092
}
9193

94+
impl RustGPUShader {
95+
pub fn help_string() -> String {
96+
let variants: Vec<String> = Self::value_variants()
97+
.iter()
98+
.map(|v| v.to_possible_value().unwrap().get_name().to_owned())
99+
.collect();
100+
format!("Shader to run [{}]", variants.join(", "))
101+
}
102+
}
103+
92104
struct CompiledShaderModules {
93105
named_spv_modules: Vec<(Option<String>, wgpu::ShaderModuleDescriptorSpirV<'static>)>,
94106
}
@@ -148,7 +160,7 @@ fn maybe_watch(
148160
.iter()
149161
.copied()
150162
.collect::<PathBuf>();
151-
163+
152164
let has_debug_printf = options.force_spirv_passthru;
153165

154166
let builder = SpirvBuilder::new(crate_path, "spirv-unknown-vulkan1.1")
@@ -224,7 +236,7 @@ fn maybe_watch(
224236
#[derive(Parser, Clone)]
225237
#[command()]
226238
pub struct Options {
227-
#[arg(short, long, default_value = "Sky")]
239+
#[arg(short, long, default_value = "Sky", help = RustGPUShader::help_string())]
228240
shader: RustGPUShader,
229241

230242
#[arg(long)]

0 commit comments

Comments
 (0)