Skip to content

refactor: move utility functions to shared package for reuse #49

@rianjs

Description

@rianjs

Summary

Useful utility functions scoped locally that could be useful elsewhere.

Current State

  • truncate() in internal/cmd/mail/labels.go:125-130
  • formatSize() in internal/cmd/mail/attachments_list.go:66-77
func truncate(s string, maxLen int) string {
    if len(s) <= maxLen {
        return s
    }
    return s[:maxLen-3] + "..."
}

func formatSize(bytes int64) string {
    // Converts bytes to human-readable format
}

Use Cases

These utilities would be useful for:

  • Future Drive integration (file sizes, names)
  • Any command that displays truncated text
  • Consistent formatting across commands

Proposed Solution

Move to internal/util or internal/format package:

package format

func Truncate(s string, maxLen int) string
func Size(bytes int64) string
func Duration(d time.Duration) string

Priority

P3 - Consider during future feature work (e.g., Drive integration)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions