main 6af0a61

bootloader.go RawHistoryFolder

1package bootloader
2
3import (
4	"errors"
5	"strconv"
6)
7
8// BootloaderType represents the bootloader implementation
9type BootloaderType int
10
11const (
12	// BootloaderTypeLimine is the Limine bootloader
13	BootloaderTypeLimine BootloaderType = iota
14)
15
16// String returns human-readable bootloader name
17func (b BootloaderType) String() string {
18	return "Limine"
19}
20
21// Bootloader is an immutable value object representing bootloader configuration
22type Bootloader struct {
23	bootType BootloaderType
24	timeout  int // seconds
25	branding string
26	efiPath  string
27}
28
29// NewBootloader creates a new Bootloader value object with validation
30func NewBootloader(bootType BootloaderType, timeoutSeconds int, branding string) (*Bootloader, error) {
31	// Validate timeout
32	if timeoutSeconds < 0 {
33		return nil, errors.New("bootloader timeout cannot be negative")
34	}
35
36	if timeoutSeconds > 600 {
37		return nil, errors.New("bootloader timeout cannot exceed 600 seconds")
38	}
39
40	// Validate branding
41	if branding == "" {
42		return nil, errors.New("bootloader branding cannot be empty")
43	}
44
45	if len(branding) > 64 {
46		return nil, errors.New("bootloader branding too long")
47	}
48
49	return &Bootloader{
50		bootType: bootType,
51		timeout:  timeoutSeconds,
52		branding: branding,
53		efiPath:  "/boot/efi",
54	}, nil
55}
56
57// Type returns the bootloader type
58func (b *Bootloader) Type() BootloaderType {
59	return b.bootType
60}
61
62// Timeout returns the bootloader timeout in seconds
63func (b *Bootloader) Timeout() int {
64	return b.timeout
65}
66
67// Branding returns the bootloader branding string
68func (b *Bootloader) Branding() string {
69	return b.branding
70}
71
72// EFIPath returns the EFI boot path
73func (b *Bootloader) EFIPath() string {
74	return b.efiPath
75}
76
77// IsLimine returns true if bootloader is Limine
78func (b *Bootloader) IsLimine() bool {
79	return b.bootType == BootloaderTypeLimine
80}
81
82// String returns human-readable representation
83func (b *Bootloader) String() string {
84	return "Bootloader(type=" + b.bootType.String() + ", timeout=" + strconv.Itoa(b.timeout) + "s)"
85}
86
87// Equals checks if two Bootloader objects are equal
88func (b *Bootloader) Equals(other *Bootloader) bool {
89	if other == nil {
90		return false
91	}
92	return b.bootType == other.bootType &&
93		b.timeout == other.timeout &&
94		b.branding == other.branding
95}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close