Skip to main content

socorro_cli/commands/
bugs.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5use crate::output::{OutputFormat, compact, json, markdown};
6use crate::{Result, SocorroClient};
7
8pub fn execute(
9    client: &SocorroClient,
10    signatures: &[String],
11    bug_ids: &[u64],
12    format: OutputFormat,
13) -> Result<()> {
14    let response = if !signatures.is_empty() {
15        client.get_bugs(signatures)?
16    } else {
17        client.get_signatures_by_bugs(bug_ids)?
18    };
19
20    let output = match format {
21        OutputFormat::Compact => {
22            let summary = response.to_summary();
23            compact::format_bugs(&summary)
24        }
25        OutputFormat::Json => json::format_bugs(&response)?,
26        OutputFormat::Markdown => {
27            let summary = response.to_summary();
28            markdown::format_bugs(&summary)
29        }
30    };
31
32    print!("{}", output);
33    Ok(())
34}