-
Notifications
You must be signed in to change notification settings - Fork 20
/
search_repositories.rs
38 lines (30 loc) · 1.04 KB
/
search_repositories.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// search_code.rs
// Search code example.
use anyhow::Result;
use azure_devops_rust_api::search;
use std::env;
mod utils;
#[tokio::main]
async fn main() -> Result<()> {
// Get authentication credential
let credential = utils::get_credential()?;
// Get ADO configuration via environment variables
let organization = env::var("ADO_ORGANIZATION").expect("Must define ADO_ORGANIZATION");
let project = env::var("ADO_PROJECT").expect("Must define ADO_PROJECT");
let repository_name = env::args()
.nth(1)
.expect("Usage: Repo name to be searched <repository-name>");
// Create a search client
println!("Create search client");
let search_client = search::ClientBuilder::new(credential).build();
// Do the search
println!("Search...");
let search_results = search_client
.repositories_client()
.get(organization, project, repository_name)
.await?;
println!("{:#?}", search_results);
Ok(())
}