Update Package Documentation (#5)

- [+] feat(docs): update client documentation to include message export functionality and usage examples
- [+] feat(docs): add export package documentation with JSON export example
- [+] chore(docs.go): add copyright notice and license agreement information

Reviewed-on: #5
Co-authored-by: H0llyW00dzZ <h0llyw00dzz@pm.me>
Co-committed-by: H0llyW00dzZ <h0llyw00dzz@pm.me>
This commit is contained in:
H0llyW00dzZ 2025-01-24 07:13:02 +00:00 committed by H0llyW00dzZ
parent ab122177c2
commit 3d17ce82ff
2 changed files with 116 additions and 3 deletions

View File

@ -5,11 +5,12 @@
// 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.
// list messages, export messages, and manage multiple user accounts.
//
// # Features
// - Connect and disconnect from an IMAP server
// - List messages in a specified mailbox
// - Export messages to various formats
// - Manage multiple users with separate IMAP clients
//
// # Usage
@ -54,7 +55,7 @@
// }
//
// for _, msg := range messages {
// fmt.Printf("ID: %s, From: %v, Subject: %s, Body: %s\n", msg.ID, msg.From, msg.Subject, msg.Body)
// fmt.Printf("ID: %s, From: %v, Subject: %s, Body: %s\n", msg[client.KeyID], msg[client.KeyFrom], msg[client.KeySubject], msg[client.KeyBody])
// }
// }
//
@ -94,7 +95,55 @@
// }
//
// for _, msg := range messages {
// fmt.Printf("ID: %s, From: %v, Subject: %s, Body: %s\n", msg.ID, msg.From, msg.Subject, msg.Body)
// fmt.Printf("ID: %s, From: %v, Subject: %s, Body: %s\n", msg[client.KeyID], msg[client.KeyFrom], msg[client.KeySubject], msg[client.KeyBody])
// }
// }
//
// Export Messages Example:
//
// package main
//
// import (
// "log"
// "os"
//
// "git.b0zal.io/H0llyW00dzZ/imap/client"
// "git.b0zal.io/H0llyW00dzZ/imap/export"
// )
//
// 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,
// }
//
// file, err := os.Create("messages.json")
// if err != nil {
// log.Fatalf("Failed to create file: %v", err)
// }
// defer file.Close()
//
// exporter := &export.JSONExporter{Encoder: export.DefaultJSONEncoder}
// err = imapClient.ExportMessagesTo(file, exporter, "INBOX", 10, messageConfig)
// if err != nil {
// log.Fatalf("Failed to export messages: %v", err)
// }
// }
package client

64
export/docs.go Normal file
View File

@ -0,0 +1,64 @@
// 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 export provides functionality to export email messages
// in various formats. It defines interfaces and implementations
// for exporting messages, allowing flexibility in how messages
// are written to different outputs.
//
// # Features
// - Define a standard interface for exporting messages
// - Implement JSON export functionality with customizable encoding
//
// # Usage
//
// JSON Export Example:
//
// package main
//
// import (
// "log"
// "os"
//
// "git.b0zal.io/H0llyW00dzZ/imap/client"
// "git.b0zal.io/H0llyW00dzZ/imap/export"
// )
//
// 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,
// }
//
// file, err := os.Create("messages.json")
// if err != nil {
// log.Fatalf("Failed to create file: %v", err)
// }
// defer file.Close()
//
// exporter := &export.JSONExporter{Encoder: export.DefaultJSONEncoder}
// err = imapClient.ExportMessagesTo(file, exporter, "INBOX", 10, messageConfig)
// if err != nil {
// log.Fatalf("Failed to export messages: %v", err)
// }
// }
package export