add cluster reroute commands, fix usage width bug (#59)

fixes #36
This commit is contained in:
T. von Dein
2026-06-29 13:08:05 +02:00
parent f9eded5f92
commit f5c8a23589
6 changed files with 466 additions and 91 deletions

View File

@@ -262,8 +262,25 @@ func HelpUsage(conf *cfg.Config) *cli.Command {
},
Action: func(ctx context.Context, cmd *cli.Command) error {
max := 22
maxCommandWidth := 0
// first pass, determine max command width
if err := walkVisible(conf, cmd.Root(), func(cmd *cli.Command) error {
path := cmd.Path()
size := len(path[len(path)-1])
if size > maxCommandWidth {
maxCommandWidth = size
}
return nil
}); err != nil {
return err
}
maxCommandWidth += 4 // account for indent width
// second pass, build tree
return walkVisible(conf, cmd.Root(), func(cmd *cli.Command) error {
path := cmd.Path()
command := path[len(path)-1]
@@ -273,7 +290,7 @@ func HelpUsage(conf *cfg.Config) *cli.Command {
}
indent := strings.Repeat(" ", len(path[1:])-1)
space := strings.Repeat(" ", max-(len(command)+len(indent)))
space := strings.Repeat(" ", maxCommandWidth-(len(command)+len(indent)))
fmt.Printf("%s%s %s - %s\n", indent, command, space, cmd.Usage)