From 4cbb43c1e2db4c90293e55f2497ae0d0d841c9bd Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 11 Jan 2024 21:06:15 +0400 Subject: Getting repository data Signed-off-by: Valentin Popov --- src/main.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 8c82ed1..48d1772 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,15 @@ +#[macro_use] +extern crate dotenv_codegen; + use clap::Parser; +use gitlab::api::{projects, Query}; +use gitlab::Gitlab; +use serde::Deserialize; + +#[derive(Debug, Deserialize)] +struct Project { + http_url_to_repo: String, +} /// Create a mirror of a repository #[derive(Parser, Debug)] @@ -13,7 +24,22 @@ struct Args { url: String, } +/* Get project info from Gitlab */ +fn get_project(url: &str) -> Project { + let gl_client = Gitlab::new(dotenv!("GITLAB_URL"), dotenv!("GITLAB_TOKEN")).unwrap(); + + let gl_endpoint = projects::Project::builder().project(url).build().unwrap(); + let gl_project: Project = gl_endpoint.query(&gl_client).unwrap(); + + gl_project +} + fn main() { + dotenv::dotenv().ok(); + let args = Args::parse(); println!("{:?}", args); + + let project = get_project(&args.url); + dbg!(project); } -- cgit v1.2.3