From b523423404854dc5b11396a28c4b607e9229bdf5 Mon Sep 17 00:00:00 2001 From: Isse Date: Sun, 28 Jan 2024 18:44:18 +0100 Subject: [PATCH 1/3] Voxygen list backends subcommand --- voxygen/src/cli.rs | 11 ++++++++++- voxygen/src/main.rs | 26 ++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/voxygen/src/cli.rs b/voxygen/src/cli.rs index 2aefc2abe9..20088bace1 100644 --- a/voxygen/src/cli.rs +++ b/voxygen/src/cli.rs @@ -7,7 +7,7 @@ //! //! Airshipper should only use arguments listed above! Since we will not try to //! be careful about their stability otherwise. -use clap::Parser; +use clap::{Parser, Subcommand}; #[derive(Parser)] pub struct Args { @@ -16,4 +16,13 @@ pub struct Args { /// This allows passing in server selection performed in airshipper. #[clap(short, long)] pub server: Option, + + #[clap(subcommand)] + pub command: Option, +} + +#[derive(Subcommand)] +pub enum Commands { + /// List available wgpu backends. + ListBackends, } diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index b8a65f6458..f58ce31932 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -42,6 +42,28 @@ use tracing::{info, warn}; use veloren_voxygen::ui::egui::EguiState; fn main() { + // Process CLI arguments + use clap::Parser; + let args = cli::Args::parse(); + + if let Some(command) = args.command { + match command { + cli::Commands::ListBackends => { + #[cfg(target_os = "windows")] + let backends = &["dx11", "dx12", "vulkan"]; + #[cfg(target_os = "linux")] + let backends = &["vulkan"]; + #[cfg(target_os = "macos")] + let backends = &["metal"]; + + for backend in backends { + println!("{backend}"); + } + return; + }, + } + } + #[cfg(feature = "tracy")] common_base::tracy_client::Client::start(); @@ -93,10 +115,6 @@ fn main() { panic_handler::set_panic_hook(log_filename, logs_dir); - // Process CLI arguments - use clap::Parser; - let args = cli::Args::parse(); - // Setup tokio runtime use common::consts::MIN_RECOMMENDED_TOKIO_THREADS; use std::sync::{ From 272837d4e5fe8a511e5cb66d962518b80c3c8aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Mon, 29 Jan 2024 16:15:19 +0100 Subject: [PATCH 2/3] add documentation for list-wgpu-backends --- voxygen/src/cli.rs | 8 ++++++-- voxygen/src/main.rs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/voxygen/src/cli.rs b/voxygen/src/cli.rs index 20088bace1..23d3a98b24 100644 --- a/voxygen/src/cli.rs +++ b/voxygen/src/cli.rs @@ -7,6 +7,9 @@ //! //! Airshipper should only use arguments listed above! Since we will not try to //! be careful about their stability otherwise. +//! +//! Likewise Airshipper should only use the following subcommands: +//! * `ListWgpuBackends` use clap::{Parser, Subcommand}; #[derive(Parser)] @@ -23,6 +26,7 @@ pub struct Args { #[derive(Subcommand)] pub enum Commands { - /// List available wgpu backends. - ListBackends, + /// List available wgpu backends. This is called by Airshipper to show a + /// dropbox of available backends + ListWgpuBackends, } diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index f58ce31932..f09999c422 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -48,7 +48,7 @@ fn main() { if let Some(command) = args.command { match command { - cli::Commands::ListBackends => { + cli::Commands::ListWgpuBackends => { #[cfg(target_os = "windows")] let backends = &["dx11", "dx12", "vulkan"]; #[cfg(target_os = "linux")] From e3b0044186d03a10f4d8957454a0403e4f5e11e8 Mon Sep 17 00:00:00 2001 From: Imbris Date: Mon, 29 Jan 2024 17:02:10 +0000 Subject: [PATCH 3/3] Add period to comment --- voxygen/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voxygen/src/cli.rs b/voxygen/src/cli.rs index 23d3a98b24..d39a0521bd 100644 --- a/voxygen/src/cli.rs +++ b/voxygen/src/cli.rs @@ -27,6 +27,6 @@ pub struct Args { #[derive(Subcommand)] pub enum Commands { /// List available wgpu backends. This is called by Airshipper to show a - /// dropbox of available backends + /// dropbox of available backends. ListWgpuBackends, }