gh_labeler/lib.rs
1//! # gh-labeler
2//!
3//! A fast and reliable GitHub repository label management library built with Rust
4//!
5//! ## Features
6//! - GitHub label synchronization
7//! - Label configuration validation
8//! - Dry-run mode
9//! - Label alias support
10
11pub mod config;
12pub mod error;
13pub mod github;
14pub mod sync;
15
16pub use config::{LabelConfig, SyncConfig};
17pub use error::{Error, Result};
18pub use github::GitHubClient;
19pub use sync::LabelSyncer;
20
21/// Main functionality of gh-labeler
22///
23/// Provides the core label management functionality of this library.
24///
25/// # Examples
26///
27/// ```rust,no_run
28/// use gh_labeler::{SyncConfig, LabelSyncer};
29///
30/// #[tokio::main]
31/// async fn main() -> anyhow::Result<()> {
32/// let config = SyncConfig {
33/// access_token: "your_github_token".to_string(),
34/// repository: "owner/repo".to_string(),
35/// dry_run: false,
36/// allow_added_labels: true,
37/// labels: None,
38/// };
39///
40/// let syncer = LabelSyncer::new(config).await?;
41/// let result = syncer.sync_labels().await?;
42///
43/// println!("Sync completed: {:?}", result);
44/// Ok(())
45/// }
46/// ```
47pub async fn sync_repository_labels(
48 access_token: &str,
49 repository: &str,
50 labels: Vec<LabelConfig>,
51 dry_run: bool,
52) -> Result<sync::SyncResult> {
53 let config = SyncConfig {
54 access_token: access_token.to_string(),
55 repository: repository.to_string(),
56 dry_run,
57 allow_added_labels: false,
58 labels: Some(labels),
59 };
60
61 let syncer = LabelSyncer::new(config).await?;
62 syncer.sync_labels().await
63}