Commit f3914854 authored by Kirill Unitsaev's avatar Kirill Unitsaev

hyprland/module: add show command

Display detailed module information including: - name, status, path, config path, line number - availability status - errors from config check Supports --format=json output. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
parent db0ba7ca
...@@ -242,3 +242,59 @@ func HyprlandModuleEditCommand(ctx context.Context, cmd *cli.Command) error { ...@@ -242,3 +242,59 @@ func HyprlandModuleEditCommand(ctx context.Context, cmd *cli.Command) error {
return nil return nil
} }
func HyprlandModuleShowCommand(ctx context.Context, cmd *cli.Command) error {
module := cmd.Args().Get(0)
if module == "" {
return fmt.Errorf("укажите имя модуля")
}
user := cmd.Bool("user")
manager, err := GetHyprlandManager(ctx)
if err != nil {
return err
}
info := manager.GetModuleInfo(module, user)
if !info.Available {
return fmt.Errorf("недопустимое название для модуля")
}
errors, _ := manager.CheckModule(module, user)
if config.IsJSON(cmd) {
jsonErrors := make([]ModuleErrorJSON, len(errors))
for i, e := range errors {
jsonErrors[i] = ModuleErrorJSON{Line: e.Line, Text: e.Text}
}
return ui.PrintJSON(ModuleShowJSON{
Name: info.Name,
Status: info.Status.Label,
Path: info.Path,
ConfPath: info.ConfPath,
LineNumber: info.LineNumber,
Available: info.Available,
Errors: jsonErrors,
})
}
fmt.Printf("Модуль: %s\n", info.Name)
fmt.Printf("Статус: %s\n", info.Status.Label)
fmt.Printf("Путь: %s\n", info.Path)
fmt.Printf("Путь в конфиге: %s\n", info.ConfPath)
fmt.Printf("Строка в конфиге: %d\n", info.LineNumber)
if info.Available {
fmt.Println("Доступен: да")
} else {
fmt.Println("Доступен: нет")
}
if len(errors) > 0 {
fmt.Printf("\nОшибки (%d):\n", len(errors))
for _, e := range errors {
fmt.Printf(" %d: %s\n", e.Line, e.Text)
}
}
return nil
}
...@@ -83,6 +83,16 @@ func CommandList() *cli.Command { ...@@ -83,6 +83,16 @@ func CommandList() *cli.Command {
ShellComplete: ShellCompleteModule("all"), ShellComplete: ShellCompleteModule("all"),
}, },
{ {
Name: "show",
Usage: "Show detailed module info",
ArgsUsage: "module",
Flags: []cli.Flag{
config.FormatFlag,
},
Action: HyprlandModuleShowCommand,
ShellComplete: ShellCompleteModule("all"),
},
{
Name: "info", Name: "info",
Usage: "Information about modules", Usage: "Information about modules",
Flags: []cli.Flag{ Flags: []cli.Flag{
......
package hyprland
type ModuleShowJSON struct {
Name string `json:"name"`
Status string `json:"status"`
Path string `json:"path"`
ConfPath string `json:"conf_path"`
LineNumber int `json:"line_number"`
Available bool `json:"available"`
Errors []ModuleErrorJSON `json:"errors"`
}
type ModuleErrorJSON struct {
Line int `json:"line"`
Text string `json:"text"`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment