Add completions to package

This commit is contained in:
Torjus Håkestad 2025-02-10 23:59:14 +01:00
parent 7db2b9f030
commit d185802c65
Signed by: torjus
SSH Key Fingerprint: SHA256:KjAds8wHfD2mBYK2H815s/+ABcSdcIHUndwHEdSxml4
4 changed files with 19 additions and 6 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
result
.direnv

View File

@ -68,6 +68,13 @@
pname = "natstonotify";
src = src;
vendorHash = "sha256-xAFxgUH2QUkmdCXJB4NzURozedgMIyawdf/g3vxOyC0=";
nativeBuildInputs = [ pkgs.installShellFiles ];
postInstall = ''
installShellCompletion --cmd natstonotify \
--bash <($out/bin/natstonotify completion bash) \
--zsh <($out/bin/natstonotify completion zsh) \
--fish <($out/bin/natstonotify completion fish)
'';
};
}
);
@ -78,6 +85,7 @@
packages = with pkgs; [
go
golangci-lint
(self.packages.${pkgs.system}.default)
];
};
}

14
main.go
View File

@ -60,8 +60,9 @@ func main() {
Usage: "NATS-powered notification service",
Commands: []*cli.Command{
{
Name: "server",
Usage: "Start the server",
Name: "server",
Usage: "Start the server",
EnableShellCompletion: true,
Action: func(ctx context.Context, cmd *cli.Command) error {
b, err := bus.NewNotifyBus()
if err != nil {
@ -105,10 +106,11 @@ func main() {
},
},
{
Name: "notify",
Aliases: []string{"n"},
Usage: "Send a notification",
ArgsUsage: "SUMMARY [BODY]",
Name: "notify",
Aliases: []string{"n"},
Usage: "Send a notification",
ArgsUsage: "SUMMARY [BODY]",
EnableShellCompletion: true,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "local",