hyprland/module: add list command

parent 6de1ba64
......@@ -276,6 +276,30 @@ func HyprlandInfoModulesCommand(ctx context.Context, cmd *cli.Command) error {
return nil
}
func HyprlandModuleListCommand(ctx context.Context, cmd *cli.Command) error {
filter := cmd.String("filter")
manager, err := GetHyprlandManager(ctx)
if err != nil {
return err
}
modules := manager.GetModulesList(filter)
if config.IsJSON(cmd) {
names := make([]string, len(modules))
for i, m := range modules {
names[i] = m.Name
}
return ui.PrintJSON(names)
}
for _, m := range modules {
fmt.Println(m.Name)
}
return nil
}
func HyprlandModuleEditCommand(ctx context.Context, cmd *cli.Command) error {
module := cmd.Args().Get(0)
manager, err := GetHyprlandManager(ctx)
......
......@@ -98,6 +98,19 @@ func CommandList() *cli.Command {
ShellComplete: ShellCompleteModule(""),
},
{
Name: "list",
Usage: locale.T("List module names"),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "filter",
Usage: locale.T("module filter (e.g. status:enabled, type:user, group:themes)"),
Aliases: []string{"f"},
},
config.FormatFlag,
},
Action: HyprlandModuleListCommand,
},
{
Name: "info",
Usage: locale.T("Information about modules"),
Flags: []cli.Flag{
......
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