Update usage examples in commands with --format flag

This commit is contained in:
Juan Carlos Mejías Rodríguez 2019-08-10 17:19:37 -04:00
parent 933f73896b
commit fb5bb20627
4 changed files with 23 additions and 1 deletions

View File

@ -19,6 +19,11 @@ var endpointGroupListCmd = &cobra.Command{
Use: "list",
Short: "List endpoint groups",
Aliases: []string{"ls"},
Example: ` Print endpoint groups in a table format:
psu endpoint group ls
Print endpoint groups name and description:
psu endpoint group ls --format "{{ .Name }}: {{ .Description }}"`,
Run: func(cmd *cobra.Command, args []string) {
client, err := common.GetClient()
common.CheckError(err)

View File

@ -35,6 +35,11 @@ var endpointListCmd = &cobra.Command{
Use: "list",
Short: "List endpoints",
Aliases: []string{"ls"},
Example: ` Print endpoints in a table format:
psu endpoint ls
Print whether an endpoint is a Swarm cluster or not:
psu endpoint ls --format "{{ .Name }} ({{ .ID }}): {{ range .Snapshots }}{{ if .Swarm }}yes{{ else }}no{{ end }}{{ end }}"`,
Run: func(cmd *cobra.Command, args []string) {
client, err := common.GetClient()
common.CheckError(err)

View File

@ -21,7 +21,14 @@ var stackListCmd = &cobra.Command{
Use: "list",
Short: "List stacks",
Aliases: []string{"ls"},
Example: "psu stack list --endpoint 1",
Example: ` Print stacks in endpoint with ID=1 in a table format:
psu stack ls --endpoint 1
Print names of stacks in endpoint with ID=1:
psu stack ls --endpoint 1 --format "{{ .Name }}"
Print environment variables of stacks in endpoint with ID=1:
psu stack ls --format "{{ .Name }}: {{ range .Env }}{{ .Name }}=\"{{ .Value }}\" {{ end }}"`,
Run: func(cmd *cobra.Command, args []string) {
portainerClient, err := common.GetClient()
common.CheckError(err)

View File

@ -16,6 +16,11 @@ import (
var statusCmd = &cobra.Command{
Use: "status",
Short: "Check Portainer status",
Example: ` Print status in a table format:
psu status
Print version of Portainer server:
psu status --format "{{ .Version }}"`,
Run: func(cmd *cobra.Command, args []string) {
client, err := common.GetClient()
common.CheckError(err)