Skip to content

add Example in cobra commands definitions #53

@feloy

Description

@feloy

Cobra Commands support an Example field, to display examples of the command when the help of the command is displayed.

Let's add meaningful examples to the different commands:

  • init
  • workspace list
  • workspace remove

Test the examples using unit tests:

Consider the Example string:

# List all workspaces (human-readable format):
kortex-cli workspace list

# List all workspaces using short alias (human-readable format):
kortex-cli list

# List workspaces in JSON format
kortex-cli workspace list --output json
  • extract from this string the commands (ignore empty lines and lines starting with #, consider lines starting with kortex-cli, and fail if other lines exist)
  • analyze the command line, and check that:
    • the command and subcommands exist
    • the flags are supported

Aliases commands will inherit Example from their original command, by replacing the original command with the alias

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions