diff --git a/cmd/cleanup.go b/cmd/cleanup.go index a9b198b..c726267 100644 --- a/cmd/cleanup.go +++ b/cmd/cleanup.go @@ -23,6 +23,7 @@ $ hcloud ssh-key list -l apricote.de/created-by=hcloud-upload-image This command does not handle any parallel executions of hcloud-upload-image and will remove in-use resources if called at the same time.`, + GroupID: "primary", RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() logger := contextlogger.From(ctx) diff --git a/cmd/root.go b/cmd/root.go index 9863f51..e654efc 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -13,6 +13,7 @@ import ( "github.com/apricote/hcloud-upload-image/hcloudimages/backoff" "github.com/apricote/hcloud-upload-image/hcloudimages/contextlogger" "github.com/apricote/hcloud-upload-image/internal/ui" + "github.com/apricote/hcloud-upload-image/internal/version" ) const ( @@ -34,6 +35,8 @@ var rootCmd = &cobra.Command{ Long: `Manage custom OS images on Hetzner Cloud.`, SilenceUsage: true, + Version: version.Version, + PersistentPreRun: func(cmd *cobra.Command, _ []string) { ctx := cmd.Context() @@ -100,4 +103,9 @@ func init() { rootCmd.SetErrPrefix("\033[1;31mError:") rootCmd.PersistentFlags().CountVarP(&verbose, flagVerbose, "v", "verbose debug output, can be specified up to 2 times") + + rootCmd.AddGroup(&cobra.Group{ + ID: "primary", + Title: "Primary Commands:", + }) } diff --git a/cmd/upload.go b/cmd/upload.go index 6692dc8..607639d 100644 --- a/cmd/upload.go +++ b/cmd/upload.go @@ -25,6 +25,7 @@ var uploadCmd = &cobra.Command{ Short: "Upload the specified disk image into your Hetzner Cloud project.", Long: `This command implements a fake "upload", by going through a real server and snapshots. This does cost a bit of money for the server.`, + GroupID: "primary", RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..44fc950 --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,19 @@ +package version + +var ( + // version is a semver version (https://semver.org). + version = "0.0.1" // x-release-please-version + + // versionPrerelease is a semver version pre-release identifier (https://semver.org). + // + // For final releases, we set this to an empty string. + versionPrerelease = "dev" + + // Version of the hcloud-upload-image CLI. + Version = func() string { + if versionPrerelease != "" { + return version + "-" + versionPrerelease + } + return version + }() +)