CLI: add --renderer argument (#4320)

* Add --renderer argument to the CLI

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Make `--platform native` work

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Emit `krates` error when cargo metadata fails

* Reinstate default "desktop" feature for examples

* Remove commented 'no platform specified' error

Signed-off-by: Nico Burns <nico@nicoburns.com>

* use the target tripple and bundle format as the source of truth for the build

* resolve renderer and bundle format

* add shorthand flags

* add headings to the help for shorthands

* resolve the renderer from the target triple if it isn't passed

* make value after --fullstack optional

* convert desktop -> mobile when targeting mobile webview

* use the new shorthand flags in the playwright tests

* fix clippy

* merge fix

* cleanup merge conflicts

* fix clippy

* remove nit

* restore platform as a legacy argument

* improve help message

* vendor openssl on native, pin server_fn

* print build errors as warnings

* add --desktop arg compat

* adjust cli headings

* prefer self.is_wasm_or_wasi()

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
This commit is contained in:
authored and GitHub committed 2025-07-22 14:32:54 -07:00
1 parent 4848e714ae
commit b257e7e8ce
28 files changed
+998 -549

No files matched your search

+11 -21
View File
@@ -14,10 +14,12 @@
//! 3. Build CLI layer for routing tracing logs to the TUI.
//! 4. Build fmt layer for non-interactive logging with a custom writer that prevents output during interactive mode.
use crate::{serve::ServeUpdate, Cli, Commands, Platform as TargetPlatform, Verbosity};
use crate::BundleFormat;
use crate::{serve::ServeUpdate, Cli, Commands, Verbosity};
use cargo_metadata::diagnostic::{Diagnostic, DiagnosticLevel};
use clap::Parser;
use futures_channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender};
use std::str::FromStr;
use std::sync::OnceLock;
use std::{
collections::HashMap,
@@ -315,7 +317,7 @@ impl Visit for CollectVisitor {
let name = field.name();
let mut value_string = String::new();
write!(value_string, "{:?}", value).unwrap();
write!(value_string, "{value:?}").unwrap();
if name == "message" {
self.message = value_string;
@@ -335,8 +337,8 @@ impl Visit for CollectVisitor {
fn format_field(field_name: &str, value: &dyn Debug) -> String {
let mut out = String::new();
match field_name {
"message" => write!(out, "{:?}", value),
_ => write!(out, "{}={:?}", field_name, value),
"message" => write!(out, "{value:?}"),
_ => write!(out, "{field_name}={value:?}"),
}
.unwrap();
@@ -391,7 +393,7 @@ impl TraceMsg {
#[derive(Clone, PartialEq)]
pub enum TraceSrc {
App(TargetPlatform),
App(BundleFormat),
Dev,
Build,
Bundle,
@@ -412,12 +414,9 @@ impl From<String> for TraceSrc {
"dev" => Self::Dev,
"bld" => Self::Build,
"cargo" => Self::Cargo,
"app" => Self::App(TargetPlatform::Web),
"windows" => Self::App(TargetPlatform::Windows),
"macos" => Self::App(TargetPlatform::MacOS),
"linux" => Self::App(TargetPlatform::Linux),
"server" => Self::App(TargetPlatform::Server),
_ => Self::Unknown,
other => BundleFormat::from_str(other)
.map(Self::App)
.unwrap_or_else(|_| Self::Unknown),
}
}
}
@@ -425,16 +424,7 @@ impl From<String> for TraceSrc {
impl Display for TraceSrc {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::App(platform) => match platform {
TargetPlatform::Web => write!(f, "web"),
TargetPlatform::MacOS => write!(f, "macos"),
TargetPlatform::Windows => write!(f, "windows"),
TargetPlatform::Linux => write!(f, "linux"),
TargetPlatform::Server => write!(f, "server"),
TargetPlatform::Ios => write!(f, "ios"),
TargetPlatform::Android => write!(f, "android"),
TargetPlatform::Liveview => write!(f, "liveview"),
},
Self::App(bundle) => write!(f, "{bundle}"),
Self::Dev => write!(f, "dev"),
Self::Build => write!(f, "build"),
Self::Cargo => write!(f, "cargo"),