From ba514f9660519c0ddee3eefdbe9c9ed4a3ba5c7f Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 10 Jan 2020 11:53:07 -0700 Subject: cmd: Add build-info command; update CertMagic --- cmd/commandfuncs.go | 20 ++++++++++++++++++++ cmd/commands.go | 6 ++++++ 2 files changed, 26 insertions(+) (limited to 'cmd') diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go index 7d88e00..422b63a 100644 --- a/cmd/commandfuncs.go +++ b/cmd/commandfuncs.go @@ -321,6 +321,26 @@ func cmdVersion(_ Flags) (int, error) { return caddy.ExitCodeSuccess, nil } +func cmdBuildInfo(fl Flags) (int, error) { + bi, ok := debug.ReadBuildInfo() + if !ok { + return caddy.ExitCodeFailedStartup, fmt.Errorf("no build information") + } + + fmt.Printf("path: %s\n", bi.Path) + fmt.Printf("main: %s %s %s\n", bi.Main.Path, bi.Main.Version, bi.Main.Sum) + fmt.Println("dependencies:") + + for _, goMod := range bi.Deps { + fmt.Printf("%s %s %s", goMod.Path, goMod.Version, goMod.Sum) + if goMod.Replace != nil { + fmt.Printf(" => %s %s %s", goMod.Replace.Path, goMod.Replace.Version, goMod.Replace.Sum) + } + fmt.Println() + } + return caddy.ExitCodeSuccess, nil +} + func cmdListModules(fl Flags) (int, error) { versions := fl.Bool("versions") diff --git a/cmd/commands.go b/cmd/commands.go index 93ebeff..87ded60 100644 --- a/cmd/commands.go +++ b/cmd/commands.go @@ -188,6 +188,12 @@ config file; otherwise the default is assumed.`, }(), }) + RegisterCommand(Command{ + Name: "build-info", + Func: cmdBuildInfo, + Short: "Prints information about this build", + }) + RegisterCommand(Command{ Name: "environ", Func: cmdEnviron, -- cgit v1.2.3