rubric/modules/linuxmodules/linux_registry.go
2026-04-06 11:02:36 +03:00

69 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package linuxmodules
import (
"fmt"
"rubric/utils"
"strings"
)
// Module описывает один раздел справочника Linux
type Module struct {
Key string
Aliases []string
Title string
Description string
Run func()
}
// All — список всех модулей в порядке меню
var All = []Module{
IntroModule,
FilesModule,
StreamsModule,
BashModule,
ProcessesModule,
UsersModule,
KernelModule,
DisksModule,
ScriptsModule,
BootModule,
LogsModule,
BackupModule,
NetworkModule,
SecurityModule,
PackagesModule,
PerformanceModule,
SysconfigModule,
NetfsModule,
ToolsModule,
}
// Find ищет модуль по ключу или алиасу
func Find(key string) (Module, bool) {
key = strings.ToLower(strings.TrimSpace(key))
for _, m := range All {
if m.Key == key {
return m, true
}
for _, a := range m.Aliases {
if a == key {
return m, true
}
}
}
return Module{}, false
}
// ListModules выводит краткий список модулей
func ListModules() {
fmt.Printf("\n%s%sРазделы справочника Linux:%s\n\n",
utils.ColorBold, utils.ColorCyan, utils.ColorReset)
for i, m := range All {
fmt.Printf(" %s%d.%s %-12s — %s\n",
utils.ColorDim, i+1, utils.ColorReset,
utils.ColorYellow+utils.ColorBold+m.Key+utils.ColorReset,
m.Title,
)
}
fmt.Println()
}