hyprland: fix silent error handling

parent 3dc7b17d
...@@ -67,8 +67,7 @@ func HyprlandModuleStatusCommand(ctx context.Context, cmd *cli.Command) error { ...@@ -67,8 +67,7 @@ func HyprlandModuleStatusCommand(ctx context.Context, cmd *cli.Command) error {
info := manager.GetModuleInfo(cmd.Args().Get(0), cmd.Bool("user")) info := manager.GetModuleInfo(cmd.Args().Get(0), cmd.Bool("user"))
if !info.Available { if !info.Available {
color.Red(locale.T("invalid module name")) return errors.New(locale.T("invalid module name"))
return nil
} }
fmt.Println(info.Status.Label) fmt.Println(info.Status.Label)
return nil return nil
......
...@@ -28,8 +28,7 @@ func CommandList() *cli.Command { ...@@ -28,8 +28,7 @@ func CommandList() *cli.Command {
if err != nil { if err != nil {
return fmt.Errorf(locale.T("failed to initialize HyprlandManager: %w"), err) return fmt.Errorf(locale.T("failed to initialize HyprlandManager: %w"), err)
} }
manager.Save() return manager.Save()
return nil
}, },
Commands: []*cli.Command{ Commands: []*cli.Command{
{ {
...@@ -254,11 +253,12 @@ func ShellCompleteVarList(ctx context.Context, cmd *cli.Command) { ...@@ -254,11 +253,12 @@ func ShellCompleteVarList(ctx context.Context, cmd *cli.Command) {
if cmd.NArg() > 0 { if cmd.NArg() > 0 {
return return
} }
manager, _ := NewHyprlandManager() manager, err := NewHyprlandManager()
if err != nil {
data := manager.Vars return
}
for _, v := range data { for _, v := range manager.Vars {
fmt.Println(v.Name) fmt.Println(v.Name)
} }
} }
...@@ -268,11 +268,12 @@ func ShellCompleteModule(filter string) func(ctx context.Context, cmd *cli.Comma ...@@ -268,11 +268,12 @@ func ShellCompleteModule(filter string) func(ctx context.Context, cmd *cli.Comma
if cmd.NArg() > 0 { if cmd.NArg() > 0 {
return return
} }
manager, _ := NewHyprlandManager() manager, err := NewHyprlandManager()
if err != nil {
userFlag := cmd.Bool("user") return
}
modules := manager.GetModulesList(userFlag, filter) modules := manager.GetModulesList(cmd.Bool("user"), filter)
for _, m := range modules { for _, m := range modules {
fmt.Println(m.Name) fmt.Println(m.Name)
} }
...@@ -284,11 +285,12 @@ func ShellCompletePlugin(filter string) func(ctx context.Context, cmd *cli.Comma ...@@ -284,11 +285,12 @@ func ShellCompletePlugin(filter string) func(ctx context.Context, cmd *cli.Comma
if cmd.NArg() > 0 { if cmd.NArg() > 0 {
return return
} }
manager, err := NewHyprlandManager()
if err != nil {
return
}
manager, _ := NewHyprlandManager() for _, t := range manager.GetPluginsList(filter) {
data := manager.GetPluginsList(filter)
for _, t := range data {
fmt.Println(t) fmt.Println(t)
} }
} }
......
...@@ -416,6 +416,8 @@ func (m *HyprlandManager) SetModule(action, module string, user, onlyNew bool) ( ...@@ -416,6 +416,8 @@ func (m *HyprlandManager) SetModule(action, module string, user, onlyNew bool) (
return fmt.Sprintf(locale.T("Module '%s' disabled"), module), nil return fmt.Sprintf(locale.T("Module '%s' disabled"), module), nil
} }
return "", fmt.Errorf(locale.T("module '%s' not changed"), module)
case "remove": case "remove":
if info.LineNumber <= 0 { if info.LineNumber <= 0 {
...@@ -426,8 +428,10 @@ func (m *HyprlandManager) SetModule(action, module string, user, onlyNew bool) ( ...@@ -426,8 +428,10 @@ func (m *HyprlandManager) SetModule(action, module string, user, onlyNew bool) (
m.removeLine(info.LineNumber) m.removeLine(info.LineNumber)
return fmt.Sprintf(locale.T("Module '%s' removed"), module), nil return fmt.Sprintf(locale.T("Module '%s' removed"), module), nil
default:
return "", fmt.Errorf(locale.T("unsupported action: %s"), action)
} }
return "", nil
} }
func (m *HyprlandManager) enableMessage(module string, disabledGroup []string) string { func (m *HyprlandManager) enableMessage(module string, disabledGroup []string) string {
...@@ -853,9 +857,10 @@ func (m *HyprlandManager) SetPlugin(action string, name string) (string, error) ...@@ -853,9 +857,10 @@ func (m *HyprlandManager) SetPlugin(action string, name string) (string, error)
return "", fmt.Errorf("%v (%s)", err, out) return "", fmt.Errorf("%v (%s)", err, out)
} }
return fmt.Sprintf(locale.T("Plugin '%s' unloaded"), name), nil return fmt.Sprintf(locale.T("Plugin '%s' unloaded"), name), nil
}
return "", nil default:
return "", fmt.Errorf(locale.T("unsupported action: %s"), action)
}
} }
// Vars // Vars
......
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