feat(cli): docs grouping and version

This commit is contained in:
Julian Tölle 2024-05-05 00:05:09 +02:00
parent d8e39159f0
commit 847b696c74
4 changed files with 29 additions and 0 deletions

View file

@ -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)

View file

@ -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:",
})
}

View file

@ -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()

View file

@ -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
}()
)