Skip to content

Commit

Permalink
fix(kraft): Various adjustments to help menu display (#1810)
Browse files Browse the repository at this point in the history
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
  • Loading branch information
craciunoiuc authored Jul 26, 2024
2 parents 4cd5494 + dd8afaa commit ef8b258
Show file tree
Hide file tree
Showing 50 changed files with 153 additions and 179 deletions.
7 changes: 7 additions & 0 deletions cmdfactory/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ func rootHelpFunc(cmd *cobra.Command, args []string) {
}

for _, c := range ungrouped {
// Add built-in subcommands `help` and `completion` into the `misc` group
// if it exists
if _, ok := mapping["misc"]; ok && c.Name() == "help" || c.Name() == "completion" {
mapping["misc"] = append(mapping["misc"], c)
continue
}

usages = append(usages, rpad(fullname(cmd, c), maxPad+2)+c.Short)
}

Expand Down
7 changes: 3 additions & 4 deletions internal/cli/kraft/cloud/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ type CertificateOptions struct{}

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&CertificateOptions{}, cobra.Command{
Short: "Manage KraftCloud TLS certificates",
Use: "certificate SUBCOMMAND",
Aliases: []string{"certificates", "cert", "certs", "crt", "crts"},
Long: "Manage KraftCloud TLS certificates.",
Short: "Manage TLS certificates",
Use: "cert SUBCOMMAND",
Aliases: []string{"certificate", "certificates", "certs", "crt", "crts"},
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-certificate",
cmdfactory.AnnotationHelpHidden: "true",
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/kraft/cloud/certificate/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func NewCmd() *cobra.Command {
Args: cobra.ExactArgs(1),
Aliases: []string{"status", "info"},
Example: heredoc.Doc(`
# Retrieve information about a kraftcloud certificate by UUID
# Retrieve information about a certificate by UUID
$ kraft cloud certificate get fd1684ea-7970-4994-92d6-61dcc7905f2b
# Retrieve information about a kraftcloud certificate by name
# Retrieve information about a certificate by name
$ kraft cloud certificate get my-certificate-431342
`),
Long: heredoc.Doc(`
Expand Down
11 changes: 4 additions & 7 deletions internal/cli/kraft/cloud/certificate/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,18 @@ func NewCmd() *cobra.Command {
Aliases: []string{"del", "delete", "rm"},
Args: cobra.ArbitraryArgs,
Example: heredoc.Doc(`
# Remove a KraftCloud certificate by UUID
# Remove a certificate by UUID
$ kraft cloud certificate remove fd1684ea-7970-4994-92d6-61dcc7905f2b
# Remove a KraftCloud certificate by name
# Remove a certificate by name
$ kraft cloud certificate remove my-certificate-431342
# Remove multiple KraftCloud certificates
# Remove multiple certificates
$ kraft cloud certificate remove my-certificate-431342 my-certificate-other-2313
# Remove all KraftCloud certificates
# Remove all certificates
$ kraft cloud certificate remove --all
`),
Long: heredoc.Doc(`
Remove a KraftCloud certificate.
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-certificate",
},
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/kraft/cloud/compose/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ type BuildOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&BuildOptions{}, cobra.Command{
Short: "Build a compose project for KraftCloud",
Short: "Build a compose project",
Use: "build [FLAGS] [COMPONENT]",
Args: cobra.ArbitraryArgs,
Aliases: []string{"b"},
Long: heredoc.Doc(`
Build a compose project for KraftCloud
Build a compose project
`),
Example: heredoc.Doc(`
# Build a compose project for KraftCloud
# Build a compose project
$ kraft cloud compose build
# (If applicable) Set or override a runtime for a particular service
Expand Down
18 changes: 9 additions & 9 deletions internal/cli/kraft/cloud/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,32 @@ type ComposeOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&ComposeOptions{}, cobra.Command{
Short: "Manage deployments on KraftCloud",
Short: "Manage Compose deployments on Unikraft Cloud",
Use: "compose",
Aliases: []string{"comp"},
Long: heredoc.Doc(`
Mange deployments KraftCloud.
Manage Compose deployments on Unikraft Cloud
`),
Example: heredoc.Doc(`
# Start the current KraftCloud deployment.
# Deploy the Compose project on Unikraft Cloud
$ kraft cloud compose up
# Stop the current KraftCloud deployment.
# Stop the deployment
$ kraft cloud compose down
# List the services in a KraftCloud deployment.
# List the Compose services for this project Unikraft Cloud
$ kraft cloud compose ps
# Build a KraftCloud deployment service.
# Build a specific service image of a Compose project
$ kraft cloud compose build nginx
# Create a service image from a KraftCloud deployment.
# Create a service image of a Compose project
$ kraft cloud compose create
# Push a KraftCloud deployment service.
# Push a service image of Compose project
$ kraft cloud compose push nginx
# Log a KraftCloud deployment service.
# View logs of a service deployment
$ kraft cloud compose log nginx
`),
Annotations: map[string]string{
Expand Down
7 changes: 2 additions & 5 deletions internal/cli/kraft/cloud/compose/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@ type CreateOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&CreateOptions{}, cobra.Command{
Short: "Create a KraftCloud deployment",
Short: "Create a deployment from a Compose project on Unikraft Cloud",
Use: "create [FLAGS] [COMPONENT]",
Args: cobra.ArbitraryArgs,
Aliases: []string{"cr"},
Long: heredoc.Doc(`
Create a service image from a KraftCloud deployment.
`),
Example: heredoc.Doc(`
# Create a service image from a KraftCloud deployment.
# Create a deployment
$ kraft cloud compose create
`),
Annotations: map[string]string{
Expand Down
9 changes: 3 additions & 6 deletions internal/cli/kraft/cloud/compose/down/down.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,15 @@ type DownOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&DownOptions{}, cobra.Command{
Short: "Stop and remove the services in a KraftCloud compose project deployment",
Short: "Stop and remove the services in a Unikraft Cloud Compose project deployment",
Use: "down [FLAGS] [COMPONENT]",
Args: cobra.ArbitraryArgs,
Aliases: []string{"d"},
Long: heredoc.Doc(`
Stop a KraftCloud deployment.
`),
Example: heredoc.Doc(`
# Stop a KraftCloud deployment fully.
# Stop a deployment and remove all instances, services and volumes.
$ kraft cloud compose down
# Stop a KraftCloud deployment with two specific components.
# Stop and remove two specific instances.
$ kraft cloud compose down nginx component2
`),
Annotations: map[string]string{
Expand Down
9 changes: 3 additions & 6 deletions internal/cli/kraft/cloud/compose/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ type ListOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&ListOptions{}, cobra.Command{
Short: "List KraftCloud deployments at a given path",
Short: "List service deployments at a given path",
Use: "ls [FLAGS] [PATH]",
Args: cobra.MaximumNArgs(1),
Aliases: []string{"l", "ls"},
Long: heredoc.Doc(`
List KraftCloud deployments at a given path.
`),
Example: heredoc.Doc(`
# List KraftCloud deployments at a given path.
# List service deployments at a given path.
$ kraft cloud compose ls /path/to/deployment
# List KraftCloud deployments in the current directory.
# List service deployments in the current directory.
$ kraft cloud compose ls
`),
Annotations: map[string]string{
Expand Down
16 changes: 7 additions & 9 deletions internal/cli/kraft/cloud/compose/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,17 @@ type LogsOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&LogsOptions{}, cobra.Command{
Short: "Log the services in a KraftCloud compose project deployment",
Short: "View logs of services in a Unikraft Cloud Compose project deployment",
Use: "log [FLAGS]",
Args: cobra.ArbitraryArgs,
Aliases: []string{"logs", "l"},
Long: heredoc.Doc(`
Log the services in a KraftCloud deployment.
`),
Aliases: []string{"log", "l"},
Example: heredoc.Doc(`
# Log the services in a KraftCloud deployment.
$ kraft cloud compose log
# Follow the logs of all service services in a Unikraft Cloud Compose
# project deployment.
$ kraft cloud compose logs -f
# Log a service in a KraftCloud deployment.
$ kraft cloud compose log nginx
# Follow the logs of a specific service
$ kraft cloud compose logs -f nginx
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-compose",
Expand Down
7 changes: 2 additions & 5 deletions internal/cli/kraft/cloud/compose/ps/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@ type PsOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&PsOptions{}, cobra.Command{
Short: "List the services of compose project deployed to KraftCloud",
Short: "List the active services of Unikraft Cloud Compose project",
Use: "ps [FLAGS]",
Args: cobra.NoArgs,
Long: heredoc.Doc(`
List the services of compose project deployed to KraftCloud.
`),
Example: heredoc.Doc(`
# List the services in a KraftCloud deployment.
# List all active services
$ kraft cloud compose ps
`),
Annotations: map[string]string{
Expand Down
7 changes: 2 additions & 5 deletions internal/cli/kraft/cloud/compose/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ type PushOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&PushOptions{}, cobra.Command{
Short: "Push a KraftCloud deployment service",
Short: "Push the images services to Unikraft Cloud from a Compose project",
Use: "push [FLAGS] [COMPONENT]",
Args: cobra.ArbitraryArgs,
Aliases: []string{"p"},
Long: heredoc.Doc(`
Push a KraftCloud deployment service.
`),
Example: heredoc.Doc(`
# Push a KraftCloud deployment service.
# Push the nginx service image to Unikraft Cloud
$ kraft cloud compose push nginx
`),
Annotations: map[string]string{
Expand Down
11 changes: 4 additions & 7 deletions internal/cli/kraft/cloud/compose/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,16 @@ type StartOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&StartOptions{}, cobra.Command{
Short: "Start a KraftCloud deployment",
Short: "Start services in a Unikraft Cloud Compose project deployment",
Use: "start [FLAGS] [COMPONENT]",
Args: cobra.ArbitraryArgs,
Aliases: []string{"str"},
Long: heredoc.Doc(`
Start an existing KraftCloud deployment.
`),
Example: heredoc.Doc(`
# Stop an existing KraftCloud deployment fully.
# Start all services in a Unikraft Cloud Compose project.
$ kraft cloud compose start
# Stop an existing KraftCloud deployment with two specific components.
$ kraft cloud compose start nginx component2
# Start the nginx service
$ kraft cloud compose start nginx
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-compose",
Expand Down
11 changes: 4 additions & 7 deletions internal/cli/kraft/cloud/compose/stop/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,16 @@ type StopOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&StopOptions{}, cobra.Command{
Short: "Stop a KraftCloud deployment",
Short: "Stop services in a Unikraft Cloud Compose project deployment",
Use: "stop [FLAGS] [COMPONENT]",
Args: cobra.ArbitraryArgs,
Aliases: []string{"s"},
Long: heredoc.Doc(`
Stop a KraftCloud deployment.
`),
Example: heredoc.Doc(`
# Stop a KraftCloud deployment fully.
# Stop all services in a Unikraft Cloud Compose project.
$ kraft cloud compose stop
# Stop a KraftCloud deployment with two specific components.
$ kraft cloud compose stop nginx component2
# Stop the nginx service
$ kraft cloud compose stop nginx
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-compose",
Expand Down
11 changes: 6 additions & 5 deletions internal/cli/kraft/cloud/compose/up/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,25 @@ type UpOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&UpOptions{}, cobra.Command{
Short: "Deploy services in a compose project to KraftCloud",
Short: "Deploy services in a compose project to Unikraft Cloud",
Use: "up [FLAGS] [COMPONENT]",
Args: cobra.ArbitraryArgs,
Aliases: []string{"u"},
Long: heredoc.Docf(`
Deploy services in a compose project to KraftCloud
Deploy services in a compose project to Unikraft Cloud
Use an existing %[1]sComposefile%[1]s or %[1]sdocker-compose.yaml%[1]s file to start a
number of services as instances on KraftCloud.
number of services as instances on Unikraft Cloud.
Note that this is an experimental command and not all attributes of the
%[1]sComposefile%[1]s are supported nor are all flags identical.
`, "`"),
Example: heredoc.Doc(`
# Start a KraftCloud deployment fully.
# Build and deploy a Compose project on Unikraft Cloud.
$ kraft cloud compose up
# Start a KraftCloud deployment with two specific components.
# Build and deploy the nginx service from a Compose project on
# Unikraft Cloud.
$ kraft cloud compose up nginx component
# (If applicable) Set or override a runtime for a particular service
Expand Down
16 changes: 14 additions & 2 deletions internal/cli/kraft/cloud/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type DeployOptions struct {
func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&DeployOptions{}, cobra.Command{
Short: "Deploy your application",
Use: "deploy",
Use: "deploy [ARGS] [CONTEXT] [-- [APP ARGS]]",
Aliases: []string{"launch", "run"},
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud",
Expand All @@ -94,8 +94,20 @@ func NewCmd() *cobra.Command {
with a single command.
`),
Example: heredoc.Docf(`
# Run an image from KraftCloud's catalog:
# Deploy a working directory with a Kraftfile or Dockerfile:
$ kraft cloud --metro fra0 deploy -p 443:8080
# Run an image from Unikraft Cloud's image catalog:
$ kraft cloud --metro fra0 deploy -p 443:8080 caddy:latest
# Supply arguments to the instance of the existing image
$ kraft cloud --metro fra0 deploy -p 443:8080 caddy:latest -- /bin/server --debug
# Supply arguments to the instance of the project (overriding the cmd):
$ kraft cloud --metro fra0 deploy -p 443:8080 . -- /bin/server --debug
# Immediately start following the log tail
$ kraft cloud --metro fra0 deploy -p 443:8080 -f caddy:latest
`),
})
if err != nil {
Expand Down
9 changes: 3 additions & 6 deletions internal/cli/kraft/cloud/img/img.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ type ImgOptions struct{}

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&ImgOptions{}, cobra.Command{
Short: "Manage images on KraftCloud",
Use: "image",
Aliases: []string{"img"},
Long: heredoc.Doc(`
Mange images on KraftCloud.
`),
Short: "Manage images",
Use: "img SUBCOMMAND",
Aliases: []string{"image"},
Example: heredoc.Doc(`
# List images in your account.
$ kraft cloud image list
Expand Down
3 changes: 0 additions & 3 deletions internal/cli/kraft/cloud/img/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ func NewCmd() *cobra.Command {
Use: "list",
Args: cobra.NoArgs,
Aliases: []string{"ls"},
Long: heredoc.Doc(`
List all images at a metro for your account.
`),
Example: heredoc.Doc(`
# List images in your account.
$ kraft cloud image list
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/kraft/cloud/instance/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ func NewCmd() *cobra.Command {
nginx:latest
`),
Long: heredoc.Doc(`
Create an instance on KraftCloud from an image.
Create an instance on Unikraft Cloud from an image.
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-instance",
Expand Down
Loading

0 comments on commit ef8b258

Please sign in to comment.