component_debug/cli/
explore.rs

1// Copyright 2023 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::explore::*;
6use crate::query::get_cml_moniker_from_query;
7use anyhow::Result;
8use {fidl_fuchsia_dash as fdash, fidl_fuchsia_sys2 as fsys};
9
10pub async fn explore_cmd(
11    query: String,
12    ns_layout: DashNamespaceLayout,
13    command: Option<String>,
14    tools_urls: Vec<String>,
15    dash_launcher: fdash::LauncherProxy,
16    realm_query: fsys::RealmQueryProxy,
17    stdout: socket_to_stdio::Stdout<'_>,
18) -> Result<()> {
19    let moniker = get_cml_moniker_from_query(&query, &realm_query).await?;
20    println!("Moniker: {}", moniker);
21
22    let (client, server) = fidl::Socket::create_stream();
23
24    explore_over_socket(moniker, server, tools_urls, command, ns_layout, &dash_launcher).await?;
25
26    #[allow(clippy::large_futures)]
27    socket_to_stdio::connect_socket_to_stdio(client, stdout).await?;
28
29    let exit_code = wait_for_shell_exit(&dash_launcher).await?;
30
31    std::process::exit(exit_code);
32}