@@ -50,13 +50,36 @@ impl eframe::App for DimosApp {
5050 }
5151}
5252
53+ /// Extract `--ws-url <value>` from args, returning (ws_url, remaining_args).
54+ /// This lets us handle our custom flag without conflicting with Rerun's own arg parsing.
55+ fn extract_ws_url ( args : Vec < String > ) -> ( Option < String > , Vec < String > ) {
56+ let mut ws_url = None ;
57+ let mut remaining = Vec :: with_capacity ( args. len ( ) ) ;
58+ let mut iter = args. into_iter ( ) ;
59+ while let Some ( arg) = iter. next ( ) {
60+ if arg == "--ws-url" {
61+ ws_url = iter. next ( ) ;
62+ } else if let Some ( val) = arg. strip_prefix ( "--ws-url=" ) {
63+ ws_url = Some ( val. to_string ( ) ) ;
64+ } else {
65+ remaining. push ( arg) ;
66+ }
67+ }
68+ ( ws_url, remaining)
69+ }
70+
5371fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
5472 let main_thread_token = re_viewer:: MainThreadToken :: i_promise_i_am_on_the_main_thread ( ) ;
5573 let build_info = re_viewer:: build_info ( ) ;
5674
75+ // Extract --ws-url before passing remaining args to Rerun
76+ let ( ws_url_arg, rerun_args) = extract_ws_url ( std:: env:: args ( ) . collect ( ) ) ;
77+
5778 // Connect WebSocket publisher for click/keyboard events
58- let ws_url = std:: env:: var ( "DIMOS_VIEWER_WS_URL" )
59- . unwrap_or_else ( |_| DEFAULT_WS_URL . to_string ( ) ) ;
79+ // Priority: --ws-url flag > DIMOS_VIEWER_WS_URL env var > default
80+ let ws_url = ws_url_arg
81+ . or_else ( || std:: env:: var ( "DIMOS_VIEWER_WS_URL" ) . ok ( ) )
82+ . unwrap_or_else ( || DEFAULT_WS_URL . to_string ( ) ) ;
6083 let ws_publisher = WsPublisher :: connect ( ws_url. clone ( ) ) ;
6184 re_log:: info!( "WebSocket client connecting to {ws_url}" ) ;
6285
@@ -142,7 +165,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
142165 main_thread_token,
143166 build_info,
144167 rerun:: CallSource :: Cli ,
145- std :: env :: args ( ) ,
168+ rerun_args . into_iter ( ) ,
146169 Some ( wrapper) ,
147170 Some ( startup_patch) ,
148171 ) ?;
0 commit comments