-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create simple version command (#174)
- Loading branch information
1 parent
5fe8259
commit bc41f09
Showing
3 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"runtime/debug" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func buildVersionCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "version", | ||
Short: "Get the version of pg-schema-diff", | ||
} | ||
cmd.RunE = func(_ *cobra.Command, _ []string) error { | ||
buildInfo, ok := debug.ReadBuildInfo() | ||
if !ok { | ||
return fmt.Errorf("build information not available") | ||
} | ||
fmt.Printf("version=%s\n", buildInfo.Main.Version) | ||
|
||
return nil | ||
} | ||
return cmd | ||
} |