rbnx/cmd/path.rs
1// SPDX-License-Identifier: MulanPSL-2.0
2// `rbnx path <key>` — print a well-known path rooted in the robonix source tree.
3// Used by package build.sh scripts in place of fragile relative-dir traversal:
4// CAPABILITIES_DIR="$(rbnx path capabilities)"
5// INTERFACES_LIB="$(rbnx path interfaces-lib)"
6
7use anyhow::Result;
8use robonix_cli::{Config, config::SourcePathKey};
9use std::str::FromStr;
10
11pub async fn execute(config: Config, key: String) -> Result<()> {
12 let parsed = SourcePathKey::from_str(&key).map_err(|e| anyhow::anyhow!(e))?;
13 let p = config.resolve_source_path(parsed)?;
14 // Print exactly one line with the absolute path — safe for `$(...)` capture.
15 println!("{}", p.display());
16 Ok(())
17}