~ser/claptrap

3 2

[PATCH]: sort commands by name

Details
Message ID
<D6AHLU7TCV78.2LAUBIFB0SE5L@posteo.net>
DKIM signature
pass
Download raw message
The order of commands in the rook manpage is shuffled around each time
them manpage is generated. Sort them so the output is stable and commands
are easier to find with the alphabeth.

(I don't know how Mercurial works so I hope this patch format is ok)

--- a/cmd/makeclapman/main.go
+++ b/cmd/makeclapman/main.go
@@ -83,6 +83,7 @@
 	}
 	//claptrap.HelpTemplate = ManTempl
 	allCommands := getAllCommands(ct.RootCommand, []string{}, []string{})
+	sort.Strings(allCommands)
 	writeOut(cmds.String("out-dir"), []string{}, ct.RootCommand, additional, allCommands, cmds.String("date"), cmds.String("version"))
 }
 
@@ -275,6 +276,7 @@
 		for k := range cmd.Commands {
 			cmdNames = append(cmdNames, k)
 		}
+		sort.Strings(cmdNames)
 		fmt.Fprintf(f, "[%s]", strings.Join(cmdNames, "|"))
 	}
 	fmt.Fprintf(f, "\n")
@@ -328,8 +328,13 @@
 	if len(cmd.Commands) > 0 {
 		fmt.Fprintf(f, ".SH COMMANDS\n")
 	}
-	for name, command := range cmd.Commands {
-		fmt.Fprintf(f, ".SS %s\n%s\n", name, command.Description)
+	cmdNames := make([]string, 0)
+	for k := range cmd.Commands {
+		cmdNames = append(cmdNames, k)
+	}
+	sort.Strings(cmdNames)
+	for _, name := range cmdNames {
+		fmt.Fprintf(f, ".SS %s\n%s\n", name, cmd.Commands[name].Description)
 	}
 }
Details
Message ID
<D6AMJYN2TFNA.2JT4WGBI23E3Q@ser1.net>
In-Reply-To
<D6AHLU7TCV78.2LAUBIFB0SE5L@posteo.net> (view parent)
DKIM signature
pass
Download raw message
Hi!

On Fri Dec 13, 2024 at 4:06 AM CST, Sertonix wrote:
> The order of commands in the rook manpage is shuffled around each time
> them manpage is generated. Sort them so the output is stable and commands
> are easier to find with the alphabeth.

Thanks for this; it's been applied and pushed as v2.4.4.

The patch was perfect. It got committed with me as the author, and I wasn't sure if you wanted your full email in the commit message, so I credited you as "sertonix".

--- SER   
Sean E. Russell    
Age: age195vpft7nzsy83medxagqqsge0lrcuf9txe3z2znlu2wsk69cdu4sx8nfvp    
GPG key: https://ser1.net/.well-known/pgp.asc
Details
Message ID
<D6AUQD0OP7IG.5F5T0RKHIFPE@posteo.net>
In-Reply-To
<D6AMJYN2TFNA.2JT4WGBI23E3Q@ser1.net> (view parent)
DKIM signature
pass
Download raw message
> Hi!
>
> On Fri Dec 13, 2024 at 4:06 AM CST, Sertonix wrote:
> > The order of commands in the rook manpage is shuffled around each time
> > them manpage is generated. Sort them so the output is stable and commands
> > are easier to find with the alphabeth.
>
> Thanks for this; it's been applied and pushed as v2.4.4.
>
> The patch was perfect. It got committed with me as the author, and I wasn't sure if you wanted your full email in the commit message, so I credited you as "sertonix".

Thanks for the quick merge! Full email would have been fine aswell.

> --- SER   
> Sean E. Russell    
> Age: age195vpft7nzsy83medxagqqsge0lrcuf9txe3z2znlu2wsk69cdu4sx8nfvp    
> GPG key: https://ser1.net/.well-known/pgp.asc    
Details
Message ID
<D6BIJHZAZ1VL.268IYDAQIIYAD@ser1.net>
In-Reply-To
<D6AUQD0OP7IG.5F5T0RKHIFPE@posteo.net> (view parent)
DKIM signature
pass
Download raw message
On Fri Dec 13, 2024 at 2:23 PM CST, Sertonix wrote:
> Thanks for the quick merge! Full email would have been fine aswell.

Of course! Thanks for the contribution.

Mercurial has a [PatchBomb extension](https://wiki.mercurial-
scm.org/PatchbombExtension), which is the easiest and gives you an `email`
command (described [here](https://man.sr.ht/hg.sr.ht/email.md)). The benefit of
this is that it preserves metadata, like the author and comment of the commit.
But what you did is just fine, and it doesn't really matter how the patches are
created.

--- SER   
Sean E. Russell    
Age: age195vpft7nzsy83medxagqqsge0lrcuf9txe3z2znlu2wsk69cdu4sx8nfvp    
GPG key: https://ser1.net/.well-known/pgp.asc
Reply to thread Export thread (mbox)