Skip to content

Commit

Permalink
feat: customize the version command
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Jul 17, 2023
1 parent 57d8855 commit 021ae4f
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion caddy/mercure/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
// Copied from https://github.com/caddyserver/xcaddy/blob/b7fd102f41e12be4735dc77b0391823989812ce8/environment.go#L251
// Adapted from https://github.com/caddyserver/xcaddy/blob/b7fd102f41e12be4735dc77b0391823989812ce8/environment.go#L251
package main

import (
"fmt"
"runtime/debug"

caddy "github.com/caddyserver/caddy/v2"
caddycmd "github.com/caddyserver/caddy/v2/cmd"

// plug in Caddy modules here.
_ "github.com/caddyserver/caddy/v2/modules/standard"
_ "github.com/dunglas/mercure/caddy"
)

//nolint:gochecknoinits
func init() {
if caddy.CustomVersion != "" {
return
}

version := "(unknown)"
if bi, ok := debug.ReadBuildInfo(); ok {
for _, m := range bi.Deps {
if m.Path == "github.com/dunglas/mercure" {
version = m.Version

break
}
}
}

caddy.CustomVersion = fmt.Sprintf("Mercure.rocks %s Caddy", version)
}

func main() {
caddycmd.Main()
}

0 comments on commit 021ae4f

Please sign in to comment.