From d6431e52982c39aa326a5aa60dbff69d7117b83a Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Fri, 24 Jan 2025 04:47:56 +0000 Subject: [PATCH] Update Documentation (#1) - [+] docs(README.md): add badges for Go Reference and Go Report Card - [+] feat(docs.go): add documentation for the client package with usage examples Reviewed-on: https://git.b0zal.io/H0llyW00dzZ/imap/pulls/1 Co-authored-by: H0llyW00dzZ Co-committed-by: H0llyW00dzZ --- README.md | 1 + client/docs.go | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 client/docs.go diff --git a/README.md b/README.md index 9fb82a8..532089d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # IMAP Client Package +[![Go Reference](https://pkg.go.dev/badge/git.b0zal.io/H0llyW00dzZ/imap.svg)](https://pkg.go.dev/git.b0zal.io/H0llyW00dzZ/imap) [![Go Report Card](https://goreportcard.com/badge/git.b0zal.io/H0llyW00dzZ/imap)](https://goreportcard.com/report/git.b0zal.io/H0llyW00dzZ/imap) This package provides a simple interface to manage IMAP connections for single or multiple users. It allows you to connect to an IMAP server, list messages, and manage multiple user accounts. diff --git a/client/docs.go b/client/docs.go new file mode 100644 index 0000000..894f784 --- /dev/null +++ b/client/docs.go @@ -0,0 +1,100 @@ +// Copyright (c) 2025 H0llyW00dzZ All rights reserved. +// +// By accessing or using this software, you agree to be bound by the terms +// of the License Agreement, which you can find at LICENSE files. + +// Package client provides a simple interface to manage IMAP connections +// for single or multiple users. It allows you to connect to an IMAP server, +// list messages, and manage multiple user accounts. +// +// # Features +// - Connect and disconnect from an IMAP server +// - List messages in a specified mailbox +// - Manage multiple users with separate IMAP clients +// +// # Usage +// +// Single User Example: +// +// package main +// +// import ( +// "fmt" +// "log" +// +// "git.b0zal.io/H0llyW00dzZ/imap/client" +// ) +// +// func main() { +// config := &client.Config{ +// Username: "user@example.com", +// Password: "password", +// Server: "imap.example.com:993", +// InsecureSkipVerify: true, +// } +// +// imapClient := client.NewIMAP(config) +// +// err := imapClient.Connect() +// if err != nil { +// log.Fatalf("Failed to connect: %v", err) +// } +// defer imapClient.Disconnect() +// +// messageConfig := client.MessageConfig{ +// GrabID: true, +// GrabFrom: true, +// GrabSubject: true, +// GrabBody: true, +// } +// +// messages, err := imapClient.ListMessages("INBOX", 10, messageConfig) +// if err != nil { +// log.Fatalf("Failed to list messages: %v", err) +// } +// +// for _, msg := range messages { +// fmt.Printf("ID: %s, From: %v, Subject: %s, Body: %s\n", msg.ID, msg.From, msg.Subject, msg.Body) +// } +// } +// +// Multiple Users Example: +// +// package main +// +// import ( +// "fmt" +// "log" +// +// "git.b0zal.io/H0llyW00dzZ/imap/client" +// ) +// +// func main() { +// multiUserIMAP := client.NewMultiUserIMAP() +// +// multiUserIMAP.AddUser("user1@example.com", "password1", "imap.example.com:993", true) +// multiUserIMAP.AddUser("user2@example.com", "password2", "imap.example.com:993", true) +// +// err := multiUserIMAP.ConnectUser("user1@example.com") +// if err != nil { +// log.Fatalf("Failed to connect user1: %v", err) +// } +// defer multiUserIMAP.DisconnectUser("user1@example.com") +// +// messageConfig := client.MessageConfig{ +// GrabID: true, +// GrabFrom: true, +// GrabSubject: true, +// GrabBody: true, +// } +// +// messages, err := multiUserIMAP.ListUserMessages("user1@example.com", "INBOX", 10, messageConfig) +// if err != nil { +// log.Fatalf("Failed to list messages for user1: %v", err) +// } +// +// for _, msg := range messages { +// fmt.Printf("ID: %s, From: %v, Subject: %s, Body: %s\n", msg.ID, msg.From, msg.Subject, msg.Body) +// } +// } +package client