Skip to content

Commit

Permalink
style(internal): Ensure all cmds have long/example/aliases (#1228)
Browse files Browse the repository at this point in the history
Approved-by: Felipe Huici <felipe@unikraft.io>
  • Loading branch information
craciunoiuc authored Feb 9, 2024
2 parents 73e9682 + ae2884a commit 7261477
Show file tree
Hide file tree
Showing 82 changed files with 474 additions and 208 deletions.
7 changes: 4 additions & 3 deletions internal/cli/kraft/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ func Build(ctx context.Context, opts *BuildOptions, args ...string) error {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&BuildOptions{}, cobra.Command{
Short: "Configure and build Unikraft unikernels",
Use: "build [FLAGS] [SUBCOMMAND|DIR]",
Args: cmdfactory.MaxDirArgs(1),
Short: "Configure and build Unikraft unikernels",
Use: "build [FLAGS] [SUBCOMMAND|DIR]",
Args: cmdfactory.MaxDirArgs(1),
Aliases: []string{"bld"},
Long: heredoc.Docf(`
Build a Unikraft unikernel.
Expand Down
7 changes: 4 additions & 3 deletions internal/cli/kraft/clean/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ func Clean(ctx context.Context, opts *CleanOptions, args ...string) error {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&CleanOptions{}, cobra.Command{
Short: "Remove the build object files of a Unikraft project",
Use: "clean [DIR]",
Args: cmdfactory.MaxDirArgs(1),
Short: "Remove the build object files of a Unikraft project",
Use: "clean [DIR]",
Args: cmdfactory.MaxDirArgs(1),
Aliases: []string{"cln"},
Long: heredoc.Doc(`
Remove the build object files of a Unikraft project`),
Example: heredoc.Doc(`
Expand Down
63 changes: 33 additions & 30 deletions internal/cli/kraft/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,51 @@ type CloudOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&CloudOptions{}, cobra.Command{
Short: "cloud",
Use: "cloud [FLAGS] [SUBCOMMAND|DIR]",
Hidden: true,
Short: "cloud",
Use: "cloud [FLAGS] [SUBCOMMAND|DIR]",
Hidden: true,
Aliases: []string{"cl"},
Long: heredoc.Docf(`
▄▀▄▀ kraft.cloud
▄▀▄▀ kraft.cloud
Manage resources on The Millisecond Platform.
Manage resources on The Millisecond Platform.
Learn more & sign up for the beta at https://kraft.cloud
Quickly switch between metros using the %[1]s--metro%[1]s flag or use the
%[1]sKRAFTCLOUD_METRO%[1]s environmental variable.
Learn more & sign up for the beta at https://kraft.cloud
Set authentication by using %[1]skraft login%[1]s or set
%[1]sKRAFTCLOUD_TOKEN%[1]s environmental variable.`, "`"),
Quickly switch between metros using the %[1]s--metro%[1]s flag or use the
%[1]sKRAFTCLOUD_METRO%[1]s environmental variable.
Set authentication by using %[1]skraft login%[1]s or set
%[1]sKRAFTCLOUD_TOKEN%[1]s environmental variable.
`, "`"),
Example: heredoc.Doc(`
# List all images in your account
$ kraft cloud img ls
# List all images in your account
$ kraft cloud image list
# List all instances in Frankfurt
$ kraft cloud --metro fra0 instance ls
# List all instances in Frankfurt
$ kraft cloud --metro fra0 instance list
# Create a new NGINX instance in Frankfurt and start it immediately
$ kraft cloud instance create -S \
-p 80:443/http+redirect \
-p 443:8080/http+tls \
nginx:latest
# Create a new NGINX instance in Frankfurt and start it immediately
$ kraft cloud instance create -S \
-p 80:443/http+redirect \
-p 443:8080/http+tls \
nginx:latest
# Get the status of an instance based on its UUID and output as JSON
$ kraft cloud --metro fra0 instance status -o json UUID
# Get the status of an instance based on its UUID and output as JSON
$ kraft cloud --metro fra0 instance status -o json UUID
# Stop an instance based on its UUID
$ kraft cloud instance stop UUID
# Stop an instance based on its UUID
$ kraft cloud instance stop UUID
# Start an instance based on its UUID
$ kraft cloud instance start UUID
# Start an instance based on its UUID
$ kraft cloud instance start UUID
# Get logs of an instance based on its UUID
$ kraft cloud instance logs UUID
# Get logs of an instance based on its UUID
$ kraft cloud instance logs UUID
# Delete an instance based on its UUID
$ kraft cloud instance rm UUID`),
# Delete an instance based on its UUID
$ kraft cloud instance remove UUID
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud",
},
Expand Down
5 changes: 5 additions & 0 deletions internal/cli/kraft/cloud/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ func NewCmd() *cobra.Command {
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud",
},
Long: heredoc.Doc(`
'kraft cloud deploy' combines a number of kraft cloud sub-commands
to enable you to build, package, ship and deploy your application
with a single command.
`),
Example: heredoc.Docf(`
# Run an image from KraftCloud's catalog:
$ kraft cloud --metro fra0 deploy -p 443:8080 caddy:latest
Expand Down
11 changes: 7 additions & 4 deletions internal/cli/kraft/cloud/img/img.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ type ImgOptions struct{}
func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&ImgOptions{}, cobra.Command{
Short: "Manage images on KraftCloud",
Use: "img",
Aliases: []string{"images", "image"},
Use: "image",
Aliases: []string{"img"},
Hidden: true,
Long: heredoc.Doc(`
Mange images on KraftCloud.
`),
Example: heredoc.Doc(`
# List images in your account.
$ kraft cloud img ls
$ kraft cloud image list
# Delete an image from your account.
$ kraft cloud img rm caddy@sha256:2ba5324141...
$ kraft cloud image remove caddy@sha256:2ba5324141...
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-img",
Expand Down
12 changes: 6 additions & 6 deletions internal/cli/kraft/cloud/img/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ type ListOptions struct {
func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&ListOptions{}, cobra.Command{
Short: "List all images at a metro for your account",
Use: "ls",
Aliases: []string{"list"},
Use: "list",
Aliases: []string{"ls"},
Long: heredoc.Doc(`
List all images in your account.
List all images at a metro for your account.
`),
Example: heredoc.Doc(`
# List images in your account.
$ kraft cloud img ls
$ kraft cloud image list
# List all images in your account.
$ kraft cloud img ls --all
$ kraft cloud image list --all
# List all images in your account in JSON format.
$ kraft cloud img ls -o json
$ kraft cloud image list -o json
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-img",
Expand Down
17 changes: 10 additions & 7 deletions internal/cli/kraft/cloud/img/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ type RemoveOptions struct {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&RemoveOptions{}, cobra.Command{
Short: "Delete an image",
Use: "rm [FLAGS] NAME[:latest|@sha256:...]",
Aliases: []string{"delete", "del", "remove"},
Short: "Remove an image",
Use: "remove [FLAGS] NAME[:latest|@sha256:...]",
Aliases: []string{"rm", "delete", "del"},
Long: heredoc.Doc(`
Remove an image for your account.
`),
Example: heredoc.Doc(`
# Delete an image from your account.
$ kraft cloud img rm caddy@sha256:2ba5324141...
# Remove an image from your account.
$ kraft cloud image remove caddy@sha256:2ba5324141...
# Delete all images from your account.
$ kraft cloud img rm --all
# Remove all images from your account.
$ kraft cloud image remove --all
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-img",
Expand Down
7 changes: 5 additions & 2 deletions internal/cli/kraft/cloud/instance/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func NewCmd() *cobra.Command {
Args: cobra.MinimumNArgs(1),
Aliases: []string{"new"},
Example: heredoc.Doc(`
# Create a new NGINX instance in Frankfurt and start it immediately. Map the external
# Create a new NGINX instance in Frankfurt and start it immediately. Map the external
# port 443 to the internal port 8080 which the application listens on.
$ kraft cloud --metro fra0 instance create \
--start \
Expand All @@ -294,14 +294,17 @@ func NewCmd() *cobra.Command {
--port 80:443/http+redirect \
nginx:latest
# Attach two existing volumes to the instance, one read-write at /data
# Attach two existing volumes to the vm, one read-write at /data
# and another read-only at /config:
$ kraft cloud --metro fra0 instance create \
--start \
--volume my-data-vol:/data \
--volume my-config-vol:/config:ro \
nginx:latest
`),
Long: heredoc.Doc(`
Create an instance on KraftCloud from an image.
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-instance",
},
Expand Down
5 changes: 4 additions & 1 deletion internal/cli/kraft/cloud/instance/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ func NewCmd() *cobra.Command {
# Retrieve information about a kraftcloud instance by name
$ kraft cloud instance get my-instance-431342
`),
`),
Long: heredoc.Doc(`
Retrieve the state of an instance.
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-instance",
},
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/kraft/cloud/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&InstanceOptions{}, cobra.Command{
Short: "Manage KraftCloud instances",
Use: "instance SUBCOMMAND",
Aliases: []string{"inst", "instances", "vm"},
Aliases: []string{"inst", "instances", "vm", "vms"},
Hidden: true,
Long: "Manage KraftCloud instances.",
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-instance",
},
Expand Down
9 changes: 6 additions & 3 deletions internal/cli/kraft/cloud/instance/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ type ListOptions struct {
func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&ListOptions{}, cobra.Command{
Short: "List instances",
Use: "ls [FLAGS]",
Aliases: []string{"list"},
Use: "list [FLAGS]",
Aliases: []string{"ls"},
Example: heredoc.Doc(`
# List all instances in your account.
$ kraft cloud instances list
$ kraft cloud instance list
`),
Long: heredoc.Doc(`
List all instances in your account.
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-instance",
Expand Down
16 changes: 10 additions & 6 deletions internal/cli/kraft/cloud/instance/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,20 @@ func Log(ctx context.Context, opts *LogOptions, args ...string) error {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&LogOptions{}, cobra.Command{
Short: "Get console output of an instance",
Use: "logs [FLAG] UUID|NAME",
Args: cobra.ExactArgs(1),
Short: "Get console output of an instance",
Use: "logs [FLAG] UUID|NAME",
Args: cobra.ExactArgs(1),
Aliases: []string{"log"},
Example: heredoc.Doc(`
# Get console output of a kraftcloud instance by UUID
$ kraft cloud inst logs 77d0316a-fbbe-488d-8618-5bf7a612477a
$ kraft cloud instance logs 77d0316a-fbbe-488d-8618-5bf7a612477a
# Get console output of a kraftcloud instance by name
$ kraft cloud inst logs my-instance-431342
`),
$ kraft cloud instance logs my-instance-431342
`),
Long: heredoc.Doc(`
Get console output of an instance.
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-instance",
},
Expand Down
24 changes: 12 additions & 12 deletions internal/cli/kraft/cloud/instance/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ func Remove(ctx context.Context, opts *RemoveOptions, args ...string) error {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&RemoveOptions{}, cobra.Command{
Short: "Delete an instance",
Use: "delete UUID|NAME",
Short: "Remove an instance",
Use: "remove UUID|NAME",
Aliases: []string{"del", "delete", "rm"},
Args: cobra.ArbitraryArgs,
Long: heredoc.Doc(`
Delete a KraftCloud instance.
`),
Example: heredoc.Doc(`
# Delete a KraftCloud instance by UUID
$ kraft cloud instance delete fd1684ea-7970-4994-92d6-61dcc7905f2b
# Remove a KraftCloud instance by UUID
$ kraft cloud instance remove fd1684ea-7970-4994-92d6-61dcc7905f2b
# Delete a KraftCloud instance by name
$ kraft cloud instance delete my-instance-431342
# Remove a KraftCloud instance by name
$ kraft cloud instance remove my-instance-431342
# Delete all KraftCloud instances
$ kraft cloud instance delete --all
`),
# Remove all KraftCloud instances
$ kraft cloud instance remove --all
`),
Long: heredoc.Doc(`
Remove a KraftCloud instance.
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-instance",
},
Expand Down
7 changes: 4 additions & 3 deletions internal/cli/kraft/cloud/instance/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ func Start(ctx context.Context, opts *StartOptions, args ...string) error {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&StartOptions{}, cobra.Command{
Short: "Start an instance",
Use: "start [FLAGS] PACKAGE|NAME",
Args: cobra.ExactArgs(1),
Short: "Start an instance",
Use: "start [FLAGS] PACKAGE|NAME",
Args: cobra.ExactArgs(1),
Aliases: []string{"st"},
Example: heredoc.Doc(`
# Start a KraftCloud instance by UUID
$ kraft cloud instance start 77d0316a-fbbe-488d-8618-5bf7a612477a
Expand Down
10 changes: 7 additions & 3 deletions internal/cli/kraft/cloud/instance/stop/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,20 @@ func Stop(ctx context.Context, opts *StopOptions, args ...string) error {

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&StopOptions{}, cobra.Command{
Short: "Stop an instance",
Use: "stop [FLAGS] UUID|NAME",
Args: cobra.ArbitraryArgs,
Short: "Stop an instance",
Use: "stop [FLAGS] UUID|NAME",
Args: cobra.ArbitraryArgs,
Aliases: []string{"st"},
Example: heredoc.Doc(`
# Stop a KraftCloud instance by UUID
$ kraft cloud instance stop 77d0316a-fbbe-488d-8618-5bf7a612477a
# Stop a KraftCloud instance by name
$ kraft cloud instance stop my-instance-431342
`),
Long: heredoc.Doc(`
Stop a KraftCloud instance.
`),
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud-instance",
},
Expand Down
3 changes: 3 additions & 0 deletions internal/cli/kraft/cloud/quotas/quotas.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func NewCmd() *cobra.Command {
Annotations: map[string]string{
cmdfactory.AnnotationHelpGroup: "kraftcloud",
},
Long: heredoc.Doc(`
View your resource quota on KraftCloud.
`),
Example: heredoc.Doc(`
# View your resource quota on KraftCloud
$ kraft cloud quota
Expand Down
Loading

0 comments on commit 7261477

Please sign in to comment.