// Data and interface definitions for bugs package buggo import ( "fmt" "github.com/charmbracelet/lipgloss" ) type Bug struct { Title string // The title of the bug in human readable format Description Field // The description of the bug Status Field // The status of the bug Tags VariadicField // A slice of [buggo.Tag] structs Blockedby VariadicField // A slice of [buggo.Blocker] structs Path string // The path to the bug machineTitle string // The machine parseable bug title } // A struct representing data that is tied to data on disk type Field struct { path string data string } // VariadicFields hold lists of Field objects. type VariadicField struct { Path string // The associated path on disk of Fields represented by Variadic Field Fields []Field // The underlying slice of Field objects } // Renders a bug as text func (b Bug) View() string { headerStyle := lipgloss.NewStyle(). Width(120). Foreground(lipgloss.Color("#00FF00")) subtitleStyle := lipgloss.NewStyle(). Width(120). Faint(true). Underline(true). Italic(true) tagsStyle := lipgloss.NewStyle(). Width(50). Italic(true) var tags string for _, tag := range b.Tags.Fields { tags = tags + string(tag.data) + ", " } var blockers string for _, blocker := range b.Blockedby.Fields { blockers = blockers + string(blocker.data) + ", " } return fmt.Sprintf("%s\n\n%s\n---\nTags:\t%s\nBlockedby:\t%s\n---\n%s", headerStyle.Render(b.Title), subtitleStyle.Render("status:\t"+b.Status.data), tagsStyle.Render(tags), tagsStyle.Render(blockers), b.Description, ) } // Parses human readable titles as path func (b *Bug) parseHumanToMachine() string { return "" } // TODO: implement! // Parses machine parseable titles as human readable func (b *Bug) parseMachineToHuman() string { return "" } // TODO: implement!