use std::str::FromStr; use giterated_api::{daemon_backend::NetworkOperationState, DaemonConnectionPool}; use giterated_models::{ authenticated::{InstanceAuthenticator, UserAuthenticator}, instance::Instance, object_backend::ObjectBackend, repository::{AccessList, Repository}, settings::AnySetting, user::{DisplayName, User}, }; use color_eyre::eyre::Result; use tokio::{fs::File, io::AsyncReadExt}; use tracing::info; #[tokio::main] async fn main() -> Result<()> { tracing_subscriber::fmt::init(); color_eyre::install()?; let pool = DaemonConnectionPool::connect_other( Instance::from_str("giterated.dev")?, ("127.0.0.1:1111").parse().unwrap(), ) .unwrap(); let mut operation_state = NetworkOperationState::new(); let mut user = pool .get_object::("ambee:giterated.dev", &operation_state) .await?; info!("Getting display name for {}!", user); let display_name = user.get::(&operation_state).await?; info!("{}'s display name is {}", user, display_name); let repositories = user .repositories( &Instance::from_str("giterated.dev").unwrap(), &operation_state, ) .await?; // info!("Repository: {:#?}", repositories); let mut repository = pool .get_object::( &repositories.first().unwrap().repository.to_string(), &operation_state, ) .await?; // info!("First repository: {}", repository.object().to_string()); // info!("First repository description: {}", repository.get::().await?); // info!("First repository visibility: {:?}", repository.get::().await?); // info!("First repository default branch: {}", repository.get::().await?); info!( "First repository info: {:#?}", repository.info(false, None, None, &operation_state).await? ); Ok(()) }