Skip to main content

sharepoint_cli/commands/
config.rs

1//! `sharepoint config show | path`
2
3use crate::cli::{ConfigCmd, Runtime};
4use crate::error::Result;
5
6pub async fn run(rt: &Runtime, cmd: ConfigCmd) -> Result<()> {
7    match cmd {
8        ConfigCmd::Show => show(rt).await,
9        ConfigCmd::Path => path_only(rt).await,
10    }
11}
12
13async fn show(rt: &Runtime) -> Result<()> {
14    let value = serde_json::json!({
15        "profile": rt.cfg.profile_name,
16        "tenant_id": rt.cfg.tenant_id,
17        "client_id": rt.cfg.client_id,
18        "default_site": rt.cfg.default_site,
19        "read_only": rt.cfg.read_only,
20        "site_aliases": rt.cfg.site_aliases,
21        "graph_endpoint": rt.cfg.graph_endpoint,
22        "login_endpoint": rt.cfg.login_endpoint,
23        "config_path": rt.config_path.display().to_string(),
24        "cache_path": rt.cache_path.display().to_string(),
25        // Tokens deliberately omitted — they are bearer secrets.
26    });
27    rt.out.print_json(&value);
28    Ok(())
29}
30
31async fn path_only(rt: &Runtime) -> Result<()> {
32    rt.out.print_data(&rt.config_path.display().to_string());
33    Ok(())
34}