Path: blob/main/components/local-app/cmd/config-context-list.go
2497 views
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package cmd56import (7"github.com/gitpod-io/local-app/pkg/config"8"github.com/gitpod-io/local-app/pkg/prettyprint"9"github.com/spf13/cobra"10)1112var configContextsListCmd = &cobra.Command{13Use: "list",14Short: "Lists the available contexts",15RunE: func(cmd *cobra.Command, args []string) error {16cmd.SilenceUsage = true1718cfg := config.FromContext(cmd.Context())1920res := make([]tabularContext, 0, len(cfg.Contexts))21for name, ctx := range cfg.Contexts {22res = append(res, tabularContext{23Active: name == cfg.ActiveContext,24Name: name,25Host: ctx.Host.String(),26Organization: ctx.OrganizationID,27})28}2930return WriteTabular(res, configContextsListpts.Format, prettyprint.WriterFormatWide)31},32}3334type tabularContext struct {35Active bool36Name string37Host string38Organization string39}4041var configContextsListpts struct {42Format formatOpts43}4445func init() {46configContextCmd.AddCommand(configContextsListCmd)47addFormatFlags(configContextsListCmd, &configContextsListpts.Format)48}495051