From 7239cd3a6bbdf12f457ae3a50507cb422f2a96d4 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Wed, 17 Sep 2025 15:10:59 +1000 Subject: [PATCH] docs: clarify 'machine init' help, --context flag description, add examples --- cmd/uncloud/machine/init.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/cmd/uncloud/machine/init.go b/cmd/uncloud/machine/init.go index 3c6a624d..46b4769c 100644 --- a/cmd/uncloud/machine/init.go +++ b/cmd/uncloud/machine/init.go @@ -34,7 +34,20 @@ func NewInitCommand() *cobra.Command { cmd := &cobra.Command{ Use: "init [USER@HOST:PORT]", Short: "Initialise a new cluster with a remote machine as the first member.", - // TODO: include usage examples of initialising a remote machine. + Long: "Initialise a new cluster by setting up a remote machine as the first member.\n" + + "This command creates a new context in your Uncloud config to manage the cluster.", + Example: ` # Initialise a new cluster with default settings. + uc machine init root@ + + # Initialise with a context name 'prod' in the Uncloud config (~/.config/uncloud/config.yaml) and machine name 'vps1'. + uc machine init root@ -c prod -n vps1 + + # Initialise with a non-root user and custom SSH port and key. + uc machine init ubuntu@:2222 -i ~/.ssh/mykey + + # Initialise without Caddy (no reverse proxy) and without an automatically managed domain name (xxxxxx.cluster.uncloud.run). + # You can deploy Caddy with 'uc caddy deploy' and reserve a domain with 'uc dns reserve' later. + uc machine init root@ --no-caddy --no-dns`, // TODO: support initialising a cluster on the local machine. Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -69,11 +82,11 @@ func NewInitCommand() *cobra.Command { ) cmd.Flags().BoolVar( &opts.noCaddy, "no-caddy", false, - "Don't deploy Caddy reverse proxy service to the machine.", + "Don't deploy Caddy reverse proxy service to the machine. You can deploy it later with 'uc caddy deploy'.", ) cmd.Flags().BoolVar( &opts.noDNS, "no-dns", false, - "Don't reserve a cluster domain in Uncloud DNS.", + "Don't reserve a cluster domain in Uncloud DNS. You can reserve it later with 'uc dns reserve'.", ) cmd.Flags().BoolVar( &opts.noInstall, "no-install", false, @@ -96,7 +109,7 @@ func NewInitCommand() *cobra.Command { ) cmd.Flags().StringVarP( &opts.context, "context", "c", cli.DefaultContextName, - "Name of the created context for the initialised cluster in the Uncloud config.", + "Name of the new context to be created in the Uncloud config to manage the cluster.", ) return cmd