mirror of
https://github.com/apricote/hcloud-upload-image.git
synced 2026-01-13 13:21:01 +00:00
docs: add generated CLI help output to repo (#46)
Generate the help pages using `cobras` builtin functionality and commit them to the repository. This gives users to ability to review the options of `hcloud-upload-image` without having to install it first.
This commit is contained in:
parent
b181eebd38
commit
4e24d83c7a
11 changed files with 188 additions and 18 deletions
|
|
@ -18,11 +18,12 @@ that match the label "apricote.de/created-by=hcloud-upload-image".
|
|||
|
||||
If you want to see a preview of what would be removed, you can use the official hcloud CLI and run:
|
||||
|
||||
$ hcloud server list -l apricote.de/created-by=hcloud-upload-image
|
||||
$ hcloud ssh-key list -l apricote.de/created-by=hcloud-upload-image
|
||||
$ hcloud server list -l apricote.de/created-by=hcloud-upload-image
|
||||
$ 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.`,
|
||||
DisableAutoGenTag: true,
|
||||
|
||||
GroupID: "primary",
|
||||
|
||||
|
|
@ -44,5 +45,5 @@ and will remove in-use resources if called at the same time.`,
|
|||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(cleanupCmd)
|
||||
RootCmd.AddCommand(cleanupCmd)
|
||||
}
|
||||
|
|
|
|||
20
cmd/root.go
20
cmd/root.go
|
|
@ -28,11 +28,13 @@ var (
|
|||
// The pre-authenticated client. Set in the root command PersistentPreRun
|
||||
var client *hcloudimages.Client
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "hcloud-upload-image",
|
||||
Long: `Manage custom OS images on Hetzner Cloud.`,
|
||||
SilenceUsage: true,
|
||||
// RootCmd represents the base command when called without any subcommands
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "hcloud-upload-image",
|
||||
Short: `Manage custom OS images on Hetzner Cloud.`,
|
||||
Long: `Manage custom OS images on Hetzner Cloud.`,
|
||||
SilenceUsage: true,
|
||||
DisableAutoGenTag: true,
|
||||
|
||||
Version: version.Version,
|
||||
|
||||
|
|
@ -98,18 +100,18 @@ func initClient(cmd *cobra.Command, _ []string) {
|
|||
}
|
||||
|
||||
func Execute() {
|
||||
err := rootCmd.Execute()
|
||||
err := RootCmd.Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.SetErrPrefix("\033[1;31mError:")
|
||||
RootCmd.SetErrPrefix("\033[1;31mError:")
|
||||
|
||||
rootCmd.PersistentFlags().CountVarP(&verbose, flagVerbose, "v", "verbose debug output, can be specified up to 2 times")
|
||||
RootCmd.PersistentFlags().CountVarP(&verbose, flagVerbose, "v", "verbose debug output, can be specified up to 2 times")
|
||||
|
||||
rootCmd.AddGroup(&cobra.Group{
|
||||
RootCmd.AddGroup(&cobra.Group{
|
||||
ID: "primary",
|
||||
Title: "Primary Commands:",
|
||||
})
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ var uploadCmd = &cobra.Command{
|
|||
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.`,
|
||||
Example: ` hcloud-upload-image upload --image-path /home/you/images/custom-linux-image-x86.bz2 --architecture x86 --compression bz2 --description "My super duper custom linux"
|
||||
hcloud-upload-image upload --image-url https://examples.com/image-arm.raw --architecture arm --labels foo=bar,version=latest
|
||||
`,
|
||||
hcloud-upload-image upload --image-url https://examples.com/image-arm.raw --architecture arm --labels foo=bar,version=latest`,
|
||||
DisableAutoGenTag: true,
|
||||
|
||||
GroupID: "primary",
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ This does cost a bit of money for the server.`,
|
|||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(uploadCmd)
|
||||
RootCmd.AddCommand(uploadCmd)
|
||||
|
||||
uploadCmd.Flags().String(uploadFlagImageURL, "", "Remote URL of the disk image that should be uploaded")
|
||||
uploadCmd.Flags().String(uploadFlagImagePath, "", "Local path to the disk image that should be uploaded")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue